Is the default hash function for the HashMap randomized?
The order of iteration over the elements of a HashMap seems to change from run to run. I know that HashMap cannot guarantee a specific order due to hashing but I thought that elements would at least always be hashed to the same position given the same conditions. Running the simple program below gives a different output every time.
use std::collections::HashMap;
fn main() {
let mut h: HashMap<i32, i32> = HashMap::new();
h.insert(1, 1);
h.insert(2, 1);
h.insert(3, 1);
h.insert(4, 1);
for i in h.keys() {
println!("{}", i);
}
}