diff --git a/agb/src/hash_map.rs b/agb/src/hash_map.rs index 2b335f62..43078152 100644 --- a/agb/src/hash_map.rs +++ b/agb/src/hash_map.rs @@ -187,6 +187,19 @@ where } } + pub fn or_insert_with_key(self, f: F) + where + F: FnOnce(&K) -> V, + { + match self { + Entry::Occupied(_) => {} + Entry::Vacant(e) => { + let value = f(&e.key); + e.map.insert(e.key, value); + } + } + } + pub fn and_modify(self, f: F) -> Self where F: FnOnce(&mut V),