Created
January 17, 2019 03:00
-
-
Save rust-play/a3bf281627a5e4f40ed40f2e6820cb36 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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