Scope of addresses: Does not live long enough
问题 I was surprised by the result of these two apparently similar programs. fn main() { let y: &int = &31i; println!("My number is {}.",*y) } //Output My number is 31. However, this code gives me an error. fn main() { let y: ∫ y = &31i; println!("My number is {}.",*y) } // Output on Rust Playpen 3:12 error: borrowed value does not live long enough 5:2 note: reference must be valid for the block at 1:10... 3:13 note: ...but borrowed value is only valid for the statement at 3:4 Apparently, &31i