Add VecMap::get_by(FnMut -> bool)

This commit is contained in:
Santiago Pastorino 2021-06-08 09:40:58 -03:00
parent c80d062084
commit dd56ec653c
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF

View file

@ -33,6 +33,13 @@ where
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
where
K: Borrow<Q>,