Trait in_place::entry::KeyMutableOccupiedEntry
source · [−]pub trait KeyMutableOccupiedEntry<'c>: KeyedOccupiedEntry<'c> {
fn replace_key<'e>(
&'e mut self,
key: Self::Key
) -> Result<Self::Key, Self::Key>;
}
Expand description
A trait to extend OccupiedEntry, allowing the user to mutate keys.
They are only able to do so through a replace_key
function, not a regular mutable reference,
so the implementer can ensure that collection invariants still hold for the new key.
Required methods
replace key with another one.
the data structure’s integrity is maintained. If the value would move in the collection (for example if the key changed hash in a hashmap) then the error state is returned, with the new_key not inserted.