Skip to content
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

Hashing &T yields different results compared to T #214

Closed
nameexhaustion opened this issue Feb 29, 2024 · 0 comments · Fixed by #213
Closed

Hashing &T yields different results compared to T #214

nameexhaustion opened this issue Feb 29, 2024 · 0 comments · Fixed by #213

Comments

@nameexhaustion
Copy link

fn test() {
    use std::hash::BuildHasher;

    let x = 10;

    println!("x: {}", x);

    let rs = ahash::RandomState::new();

    println!("ahash hash_one(x)  {}", rs.clone().hash_one(x));
    println!("ahash hash_one(&x) {}", rs.clone().hash_one(&x));

    let rs = std::hash::RandomState::new();

    println!("std hash_one(x)    {}", rs.clone().hash_one(x));
    println!("std hash_one(&x)   {}", rs.clone().hash_one(&x));
}
x: 10
ahash hash_one(x)  3042556146200844667
ahash hash_one(&x) 14656816703936529722
std hash_one(x)    3528508081386770256
std hash_one(&x)   3528508081386770256

I believe this is not desirable behavior, I would instead expect hash(x) <=> hash(&x). This appears to be due to missing an impl for hash specialization on &T where T is a type that has specialized hash impls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant