1
0
Fork 0
forked from wry/wry

autocommit 2022-01-08 16:57:40 CET

This commit is contained in:
Julian Orth 2022-01-08 16:57:40 +01:00
parent f8e7557d1d
commit 33549184d4
42 changed files with 2072 additions and 190 deletions

View file

@ -28,6 +28,14 @@ impl<K: Eq + Hash, V: Clone> CopyHashMap<K, V> {
self.map.borrow_mut().get(k).cloned()
}
pub fn get_or_insert_default(&self, k: K) -> V
where
V: Default,
{
let mut map = self.map.borrow_mut();
map.entry(k).or_insert_with(|| Default::default()).clone()
}
pub fn remove(&self, k: &K) -> Option<V> {
self.map.borrow_mut().remove(k)
}