Skip to content

Commit dd56ec6

Browse files
committed
Add VecMap::get_by(FnMut -> bool)
1 parent c80d062 commit dd56ec6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

compiler/rustc_data_structures/src/vec_map.rs

+7
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ where
3333
self.0.iter().find(|(key, _)| k == key.borrow()).map(|elem| &elem.1)
3434
}
3535

36+
pub fn get_by<P>(&self, predicate: P) -> Option<&V>
37+
where
38+
for<'b> P: FnMut(&'b &(K, V)) -> bool,
39+
{
40+
self.0.iter().find(predicate).map(|elem| &elem.1)
41+
}
42+
3643
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> bool
3744
where
3845
K: Borrow<Q>,

0 commit comments

Comments
 (0)