Closed
Description
HashMap
has this method:
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Hash + Eq
{
self.search(k).map(|bucket| bucket.into_refs().1)
}
I’d like to add this one, where the only difference is removing .1
:
pub fn get_pair<Q: ?Sized>(&self, k: &Q) -> Option<(&K, &V)>
where K: Borrow<Q>, Q: Hash + Eq
{
self.search(k).map(|bucket| bucket.into_refs())
}
This can be useful when K
is &'a T
where 'a
is a longer lifetime than in Q
.
Is this too obscure to pull its weight in std
?
CC @gankro
Metadata
Metadata
Assignees
Labels
No labels