I do run into them even though I use Rust for ~3 years now, but only in non-obvious cases, e. g. when all references to the borrowed data are dropped before the end of the function.
Website | Codeberg | GitHub | Altes Profil
Verantwortlich für @[email protected] & @[email protected].
- 0 Posts
- 5 Comments
Joined 1 year ago
Cake day: June 22nd, 2024
You are not logged in. If you use a Fediverse account that is able to follow users, you can follow this user.
Rust would be some borrow checker compile error like
borrowed data escapes outside of associated function
argument requires that `'1` must outlive `'static`
d_k_bo@feddit.orgto Programmer Humor@programming.dev•Python needs an actual default function7·14 days agoFree standing functions in Java?! This can’t be true.
d_k_bo@feddit.orgto Programmer Humor@programming.dev•Python needs an actual default function385·15 days agoStill better than having to create a new class just to implement
public static void main(String[] args) {}
Relevant Fireship video: https://youtu.be/m4-HM_sCvtQ
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