about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/vec_map.rs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_data_structures/src/vec_map.rs')
-rw-r--r--compiler/rustc_data_structures/src/vec_map.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/vec_map.rs b/compiler/rustc_data_structures/src/vec_map.rs
index cc7ec9432fa..8f525230e7e 100644
--- a/compiler/rustc_data_structures/src/vec_map.rs
+++ b/compiler/rustc_data_structures/src/vec_map.rs
@@ -30,6 +30,11 @@ where
         }
     }
 
+    /// Removes the entry from the map and returns the removed value
+    pub fn remove(&mut self, k: &K) -> Option<V> {
+        self.0.iter().position(|(k2, _)| k2 == k).map(|pos| self.0.remove(pos).1)
+    }
+
     /// Gets a reference to the value in the entry.
     pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>
     where