Trait map_ext::UpdateOr
[−]
[src]
pub trait UpdateOr<K, V> { fn update_or<F>(&mut self, key: &K, f: F, default: V)
where
F: FnOnce(&mut V); }
Trait adding an update_or
method to maps, allowing their entries to be
updated with a default value.
Required Methods
fn update_or<F>(&mut self, key: &K, f: F, default: V) where
F: FnOnce(&mut V),
F: FnOnce(&mut V),
Update the entry for given key, or insert a default.
If there is an entry in the map corresponding to key
, updates the
value by applying the function f
to it. Otherwise, if there is
no entry, inserts the default value into the map for that key.
Arguments
key
: the key to the entry to updatef
: a function taking&mut V
to update the entry's valuedefault
: a default value to insert if there is no existing value