Might be worth noting that "dropped" in this context doesn't necessarily correspond to the reference going out of scope:
fn get_first(v: &Vec<i32>) -> &i32 { &v[0] } fn main() { let mut v = vec![0, 1, 2]; let first = get_first(&v); print!("{}", first}); v.push(3); // Works! // print!("{}", first); // Doesn't work }
Might be worth noting that "dropped" in this context doesn't necessarily correspond to the reference going out of scope: