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

HashSet will accept duplicate HashSets #211

Open
RyanMarcus opened this issue Oct 17, 2023 · 0 comments
Open

HashSet will accept duplicate HashSets #211

RyanMarcus opened this issue Oct 17, 2023 · 0 comments

Comments

@RyanMarcus
Copy link

This behavior was quite surprising to me:

use im::{hashset};

fn main() {
    let hs1 = hashset![1, 2, 3];
    let hs2 = hashset![3, 2, 1];
    println!("{}", hs1 == hs2);

    let hshs = hashset![hs1, hs2];
    println!("{:?}", hshs.len());
}

Output:

true
2

I had expected the length of hshs to be one, since hs1 is equal to hs2.

I am not sure if this is an error in HashSet's Hash implementation (e.g., hs1 == hs2 but h(hs1) != h(hs2)) or me misunderstanding the semantics of HashSet.

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

No branches or pull requests

1 participant