Closed
Description
Sorry, I'm not sure how to describe this very well in a sentence. I am able to mutably borrow the innermost values of a HashMap<u32, Vec<int>>
, delete the values, then reference them after they were deleted. This code compiles, runs, and barfs out strange numbers.
use std::collections::HashMap;
fn main() {
let mut my_stuff: HashMap<u32, Vec<int>> = HashMap::new();
my_stuff.insert(0, vec![1, 2, 3, 4]);
// Do bad things
let mut stuff = vec!();
for (_, vec) in my_stuff.mut_iter() {
for thing in vec.mut_iter() {
stuff.push(thing);
}
}
my_stuff.clear();
for thing in stuff.iter() {
println!("{}", *thing);
}
}