Skip to content

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

Description

@apasel422
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.

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
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions