Skip to content

Instantly share code, notes, and snippets.

@rust-play
Created January 17, 2019 03:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rust-play/a3bf281627a5e4f40ed40f2e6820cb36 to your computer and use it in GitHub Desktop.
Save rust-play/a3bf281627a5e4f40ed40f2e6820cb36 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
struct Foo<'a> {
bar: &'a i32
}
/*impl<'a, 'b: 'a> Foo<'b> {
fn new(bar: &'b i32) -> Self {
Foo { bar }
}
fn qux(&'a mut self) -> &'b i32 {
self.bar
}
}*/
impl<'a> Foo<'a> {
fn qux(&'a mut self) -> &'a i32 {
self.bar
}
}
fn main() {
let aaaaa = 0;
let mut f = Foo { bar: &aaaaa };
let a = f.qux();
let b = f.qux();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment