Why does hashing the same vector twice get different hash codes?
hash, rust, vector
Solution
The hasher is not reset after `finish`. Create a new hasher state with `DefaultHasher::new()` for each hash value you want to compute.
Problem
I want to get the hash code of this vector: ``` let vec = vec![1,2,3]; let tmp = vec![1,2,3]; let mut hash = DefaultHasher::new(); vec.hash(&mut hash); println!("{}", hash.finish()); tmp.hash(&mut hash); println!("{}", hash.finish()); ``` However the output is: ``` 13585085576907263210 8618793686565720431 ``` What's going on? I have tried multiple times and always get the same result. I want the vector with the same elements to hash to the same hash code.