1 This error occurs because a value was dropped while it was still borrowed
3 Erroneous code example:
10 let mut x = Foo { x: None };
13 x.x = Some(&y); // error: `y` does not live long enough
15 println!("{:?}", x.x);
18 In here, `y` is dropped at the end of the inner scope, but it is borrowed by
19 `x` until the `println`. To fix the previous example, just remove the scope
20 so that `y` isn't dropped until after the println
27 let mut x = Foo { x: None };
32 println!("{:?}", x.x);