Add VecMap::get_by(FnMut -> bool)
This commit is contained in:
parent
c80d062084
commit
dd56ec653c
1 changed files with 7 additions and 0 deletions
|
@ -33,6 +33,13 @@ where
|
||||||
self.0.iter().find(|(key, _)| k == key.borrow()).map(|elem| &elem.1)
|
self.0.iter().find(|(key, _)| k == key.borrow()).map(|elem| &elem.1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_by<P>(&self, predicate: P) -> Option<&V>
|
||||||
|
where
|
||||||
|
for<'b> P: FnMut(&'b &(K, V)) -> bool,
|
||||||
|
{
|
||||||
|
self.0.iter().find(predicate).map(|elem| &elem.1)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
|
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
|
||||||
where
|
where
|
||||||
K: Borrow<Q>,
|
K: Borrow<Q>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue