Skip to content

HashSet will accept duplicate HashSets #211

@RyanMarcus

Description

@RyanMarcus

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions