Skip to content

Add a function to get the key from a HashMap #43143

Description

@iqualfragile

Basically just

pub fn get_both<Q: ?Sized>(&self, k: &Q) -> Option<(&K,&V)>
        where K: Borrow<Q>,
              Q: Hash + Eq
    {
        self.search(k).into_occupied_bucket().map(|bucket| bucket.into_refs())
}

sometimes you need a reference to a key with the lifetime of the collection.

Activity

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

    C-feature-acceptedCategory: A feature request that has been accepted pending implementation.T-libs-api[DEPRECATED; DO NOT USE]

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions