diff options
| author | Oli Scherer <github35764891676564198441@oli-obk.de> | 2021-08-13 17:19:26 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2022-02-02 15:40:10 +0000 |
| commit | d49b0746f6c0cf41e94e4bbd1592c52082a9cad7 (patch) | |
| tree | 852d775a707c3932ff1c0648e3b5e9c637d35088 /compiler/rustc_data_structures | |
| parent | dca1e7aa5a8ac05ddaea731f4eab20de91acb46b (diff) | |
| download | rust-d49b0746f6c0cf41e94e4bbd1592c52082a9cad7.tar.gz rust-d49b0746f6c0cf41e94e4bbd1592c52082a9cad7.zip | |
Add roll back infrastructure for opaque type caches
Diffstat (limited to 'compiler/rustc_data_structures')
| -rw-r--r-- | compiler/rustc_data_structures/src/vec_map.rs | 5 |
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 |
