autocommit 2022-01-08 16:57:40 CET
This commit is contained in:
parent
f8e7557d1d
commit
33549184d4
42 changed files with 2072 additions and 190 deletions
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue