cm0002@lemmy.world to Programmer Humor@programming.dev · 1 day agoThe meaning of thislemmy.worldimagemessage-square12linkfedilinkarrow-up1302arrow-down18
arrow-up1294arrow-down1imageThe meaning of thislemmy.worldcm0002@lemmy.world to Programmer Humor@programming.dev · 1 day agomessage-square12linkfedilink
minus-squared_k_bo@feddit.orglinkfedilinkarrow-up5·edit-215 hours agothis is commonly used with a similar meaning to self in cases where self can’t be used because it is a reserved keyword. Example: fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<St1::Item>> { let this = self.project(); this.inner.poll_next(cx) } https://github.com/rust-lang/futures-rs/blob/master/futures-util/src/stream/select.rs#L113-L116
this
is commonly used with a similar meaning toself
in cases whereself
can’t be used because it is a reserved keyword.Example:
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<St1::Item>> { let this = self.project(); this.inner.poll_next(cx) }
https://github.com/rust-lang/futures-rs/blob/master/futures-util/src/stream/select.rs#L113-L116