Skip to content

Instantly share code, notes, and snippets.

@abernier
Forked from rust-play/playground.rs
Created September 22, 2019 13:26
Show Gist options
  • Save abernier/bf04538979b2269744ab050fad11616f to your computer and use it in GitHub Desktop.
Save abernier/bf04538979b2269744ab050fad11616f to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
struct A {
a : i32,
}
impl A {
fn bind_lifetime_mut(&mut self) -> &i32 {
return &self.a;
}
fn legal(&mut self) -> &i32 {
self.bind_lifetime_mut();
return self.bind_lifetime_mut();
}
fn not_legal(&mut self) -> &i32 {
let test_ret = self.bind_lifetime_mut();
if *test_ret == 1 {
return test_ret;
}
return self.bind_lifetime_mut()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment