Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created September 22, 2019 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rust-play/86e29ba09024fe31426a2741e3d7f658 to your computer and use it in GitHub Desktop.
Save rust-play/86e29ba09024fe31426a2741e3d7f658 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