Add roll back infrastructure for opaque type caches

This commit is contained in:
Oli Scherer
2021-08-13 17:19:26 +00:00
committed by Oli Scherer
parent dca1e7aa5a
commit d49b0746f6
10 changed files with 113 additions and 37 deletions

View File

@@ -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