Explicitly pass find arguments down the predicate so coercions can apply

This commit is contained in:
Santiago Pastorino 2021-06-08 16:50:33 -03:00
parent 0ad09f9386
commit ed94da14ed
No known key found for this signature in database
GPG key ID: 8131A24E0C79EFAF

View file

@ -33,11 +33,11 @@ where
self.0.iter().find(|(key, _)| k == key.borrow()).map(|elem| &elem.1)
}
pub fn get_by<P>(&self, predicate: P) -> Option<&V>
pub fn get_by<P>(&self, mut predicate: P) -> Option<&V>
where
for<'b> P: FnMut(&'b &(K, V)) -> bool,
{
self.0.iter().find(predicate).map(|elem| &elem.1)
self.0.iter().find(|kv| predicate(kv)).map(|elem| &elem.1)
}
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool