Use impl FnMut directly as predicate type

This commit is contained in:
Santiago Pastorino 2021-06-08 16:52:33 -03:00
parent ed94da14ed
commit cad762b1e2
No known key found for this signature in database
GPG Key ID: 8131A24E0C79EFAF
1 changed files with 1 additions and 4 deletions

View File

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