Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fn main() {
- foo();
- }
- fn foo() {
- let x = 5;
- let mut xr = &x; // Ok - x and xr have the same lifetime
- {
- let y = 6;
- xr = &y // Error - xr will outlive y
- } // y is released here
- } // x and xr are released here
Add Comment
Please, Sign In to add comment