Why does the borrow from `HashMap::get` not end when the function returns?
Here is emulation of my problem, when a borrow ends too late use std::collections::HashMap; struct Item { capacity: u64 } struct Petrol { name: String, fuel: HashMap<&'static str, Item> } fn buy_gaz(p: &mut Petrol) { match p.fuel.get("gaz") { Some(gaz) => { fire_petrol(p); } None => () } } fn fire_petrol(p: &mut Petrol) { println!("Boom!"); p.fuel.remove("gaz"); p.fuel.remove("benzin"); } fn main() { let mut bt = Petrol { name: "Britii Petrovich".to_string(), fuel: HashMap::new() }; bt.fuel.insert("gaz", Item { capacity: 1000 }); bt.fuel.insert("benzin", Item { capacity: 5000 }); buy_gaz(&mut