about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src
diff options
context:
space:
mode:
authorSantiago Pastorino <spastorino@gmail.com>2021-06-08 09:40:58 -0300
committerSantiago Pastorino <spastorino@gmail.com>2021-06-08 09:40:58 -0300
commitdd56ec653cec248fb532fc295e1c40271238cffc (patch)
tree45de42ef776fdb79e7c67b81aad4b09d9a6b5c1b /compiler/rustc_data_structures/src
parentc80d0620842968afdb327a039b42c3847d478cae (diff)
downloadrust-dd56ec653cec248fb532fc295e1c40271238cffc.tar.gz
rust-dd56ec653cec248fb532fc295e1c40271238cffc.zip
Add VecMap::get_by(FnMut -> bool)
Diffstat (limited to 'compiler/rustc_data_structures/src')
-rw-r--r--compiler/rustc_data_structures/src/vec_map.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/vec_map.rs b/compiler/rustc_data_structures/src/vec_map.rs
index eca4ff212ac..fef570c786b 100644
--- a/compiler/rustc_data_structures/src/vec_map.rs
+++ b/compiler/rustc_data_structures/src/vec_map.rs
@@ -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>,