mirror of
https://github.com/italicsjenga/agb.git
synced 2025-01-11 17:41:33 +11:00
Also implement or_insert_with_key
This commit is contained in:
parent
ab80f200e8
commit
86635752af
|
@ -187,6 +187,19 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub fn or_insert_with_key<F>(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<F>(self, f: F) -> Self
|
||||
where
|
||||
F: FnOnce(&mut V),
|
||||
|
|
Loading…
Reference in a new issue