From dd56ec653cec248fb532fc295e1c40271238cffc Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 8 Jun 2021 09:40:58 -0300 Subject: Add VecMap::get_by(FnMut -> bool) --- compiler/rustc_data_structures/src/vec_map.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'compiler/rustc_data_structures') 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

(&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(&self, k: &Q) -> bool where K: Borrow, -- cgit 1.4.1-3-g733a5