Guest User

Untitled

a guest
Jul 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #![feature(nll)]
  2.  
  3. fn main() {
  4. let mut vec = vec![1, 2, 3];
  5.  
  6. // Borrow created here
  7. let x = &mut vec;
  8. x.push(4);
  9. // `x` isn't used after this point
  10. // so the borrow is dropped before `println!`
  11.  
  12. // This wont compile with lexical lifetimes
  13. // because `x` lasts until end of scope
  14. println!("{:?}", vec);
  15. }
Add Comment
Please, Sign In to add comment