Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 };
- println!("{}", f.qux());
- println!("{}", f.qux());
- println!("{}", f.qux());
- println!("{}", f.qux());
- }
Add Comment
Please, Sign In to add comment