Skip to content

HashMap and HashSet should provide a getter for their hashers #31262

Closed
@apasel422

Description

@apasel422
Contributor
impl<K: Eq + Hash, V, S: BuildHasher> HashMap<K, V, S> {
    pub fn hasher(&self) -> &S { &self.hash_builder }
}

impl<T: Eq + Hash, S: BuildHasher> HashSet<T, S> {
    pub fn hasher(&self) -> &S { self.map.hasher() }
}

This would let us close contain-rs/linked-hash-map#3, and likely has other (niche) uses for code that needs to reproduce hashes.

Activity

rthomas

rthomas commented on Feb 2, 2016

@rthomas
Contributor

I'd be interested in taking this one on.

rthomas

rthomas commented on Feb 9, 2016

@rthomas
Contributor

As per @gankro s suggestion I've put this behind an unstable feature flag hashmap_public_hasher.

rthomas

rthomas commented on Feb 11, 2016

@rthomas
Contributor

This has been merged, this issue can now be closed.

apasel422

apasel422 commented on Feb 11, 2016

@apasel422
ContributorAuthor

@rthomas This actually needs to stay open to track the stability of the newly added methods.

added
B-unstableBlocker: Implemented in the nightly compiler and unstable.
on Feb 11, 2016
added
T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.
on Mar 7, 2016
alexcrichton

alexcrichton commented on Mar 11, 2016

@alexcrichton
Member

🔔 This issue is now entering its cycle-long final comment period for stabilization in 1.9 🔔

added
final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.
on Mar 11, 2016

12 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-collectionsArea: `std::collections`B-unstableBlocker: Implemented in the nightly compiler and unstable.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.final-comment-periodIn the final comment period and will be merged soon unless new substantive objections are raised.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @alexcrichton@rthomas@sfackler@apasel422

        Issue actions

          `HashMap` and `HashSet` should provide a getter for their hashers · Issue #31262 · rust-lang/rust