struct Player { x: i16, y: i16, } fn add_player(players: &mut Vec<&mut Player>) { let mut player = Box::new(Player { x: 0, y: 0 }); players.push(&mut player); } fn main() { let mut players: Vec<&mut Player> = Vec::new(); add_player(&mut players); } error[E0597]: `player` does not live long enough --> src/main.rs:8:18 | 6 | fn add_player(players: &mut Vec<&mut Player>) { | - let's call the lifetime of this reference `'1` 7 | let mut player = Box::new(Player { x: 0, y: 0 }); 8 | players.push(&mut player); | -------------^^^^^^^^^^^- | | | | | borrowed value does not live long enough | argument requires that `player` is borrowed for `'1` 9 | } | - `player` dropped here while still borrowed For more information about this error, try `rustc --explain E0597`. error: could not compile `rs-test` due to previous error