Guest User

Untitled

a guest
Jul 16th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. fn main() {
  2. foo();
  3. }
  4.  
  5. fn foo() {
  6. let x = 5;
  7. let mut xr = &x; // Ok - x and xr have the same lifetime
  8. {
  9. let y = 6;
  10. xr = &y // Error - xr will outlive y
  11. } // y is released here
  12. } // x and xr are released here
Add Comment
Please, Sign In to add comment