cm0002@lemmy.world to Programmer Humor@programming.dev · 5 months agoThe meaning of thislemmy.worldexternal-linkmessage-square14fedilinkarrow-up1318arrow-down19
arrow-up1309arrow-down1external-linkThe meaning of thislemmy.worldcm0002@lemmy.world to Programmer Humor@programming.dev · 5 months agomessage-square14fedilink
minus-squared_k_bo@feddit.orglinkfedilinkarrow-up6·edit-25 months 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
thisis commonly used with a similar meaning toselfin cases whereselfcan’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