-
Notifications
You must be signed in to change notification settings - Fork 298
hashset::contains() returns FALSE, although the item is in the set #218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Another, cleaner example:
it seems that the issue occurs only with |
This is odd since |
I tried to bisect this, but it just took me to 182d3e3, "Replace FxHash with AHash as the default hasher." |
It seems use ahash::AHasher;
use std::collections::VecDeque;
use std::hash::{Hash, Hasher};
fn hash(x: &impl Hash) -> u64 {
let mut hasher = AHasher::default();
Hash::hash(x, &mut hasher);
hasher.finish()
}
fn main() {
let deque: VecDeque<i32> = (0..10).collect();
let mut deque2 = deque.clone();
deque2.rotate_left(5);
deque2.rotate_left(5);
assert_eq!(deque, deque2);
assert_eq!(hash(&deque), hash(&deque2)); // fails!
} |
This feels like a bug in |
You are right:
After rotation, the deque is split in a different way:
|
I'm going to close this since it isn't a bug in |
It doesn't directly hash the slices, but calls |
Well it's either a bug in |
While playing AoC 2020 I've encountered a very strange issue with
HashSet::contains()
- it reports that an item is NOT present in the set, although it is. Here is a MCVE:Expected behavior:
The application does not print anything
Actual behavior
The application prints:
The issue is NOT reproducible with
std::collections::HashSet
. Just comment out the hashbrown import and uncomment the std one.Hashbrown version: 0.9.1
rustc 1.48.0 (7eac88abb 2020-11-16)
The text was updated successfully, but these errors were encountered: