Skip to content

HashSet operations against another HashSet should allow for differing hash algorithms #31712

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

Open
shepmaster opened this issue Feb 16, 2016 · 2 comments
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@shepmaster
Copy link
Member

Operations such as intersection take a second HashMap. It's required that the second HashMap implement the same hashing algorithm as the first one:

impl<T, S> HashSet<T, S>
    where T: Eq + Hash,
          S: HashState
{
    fn intersection<'a>(&'a self, other: &'a HashSet<T, S>) -> Intersection<'a, T, S>;
}

This means that you cannot intersect a HashMap<u8, SipHash> against a HashMap<u8, FnvHash>. This seems overly restrictive.

/cc @bluss

@bluss
Copy link
Member

bluss commented Feb 16, 2016

With FnvHash it doesn't need to recompute hashes either. But we should not stall on that, this change is more likely to introduce type inference regressions the longer custom hasher support is stable.

@nagisa nagisa added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Feb 17, 2016
@Mark-Simulacrum Mark-Simulacrum added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jul 24, 2017
varkor added a commit to varkor/rust that referenced this issue Feb 20, 2018
Allow the two sets that are parameters in `HashSet::{difference, intersection, is_disjoint, is_subset, is_superset}` to have different hashing algorithms. Fixes rust-lang#31712.
bors added a commit that referenced this issue Mar 6, 2018
…<try>

Allow binary HashSet operations to be generic over hashers

Allow the two sets that are parameters in `HashSet::{difference, intersection, is_disjoint, is_subset, is_superset}` to have different hashing algorithms. Fixes #31712.
@steveklabnik
Copy link
Member

Triage: not aware of any changes here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: An issue proposing an enhancement or a PR with one. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants