Trait indexmap::map::MutableEntryKey

source ·
pub trait MutableEntryKey: Sealed {
    type Key;

    // Required method
    fn key_mut(&mut self) -> &mut Self::Key;
}
Expand description

Opt-in mutable access to Entry keys.

These methods expose &mut K, mutable references to the key as it is stored in the map. You are allowed to modify the keys in the map if the modification does not change the key’s hash and equality.

If keys are modified erroneously, you can no longer look them up. This is sound (memory safe) but a logical error hazard (just like implementing PartialEq, Eq, or Hash incorrectly would be).

use this trait to enable its methods for Entry.

This trait is sealed and cannot be implemented for types outside this crate.

Required Associated Types§

Required Methods§

source

fn key_mut(&mut self) -> &mut Self::Key

Gets a mutable reference to the entry’s key, either within the map if occupied, or else the new key that was used to find the entry.

Implementors§

source§

impl<K, V> MutableEntryKey for Entry<'_, K, V>

Opt-in mutable access to Entry keys.

See MutableEntryKey for more information.

§

type Key = K

source§

impl<K, V> MutableEntryKey for IndexedEntry<'_, K, V>

Opt-in mutable access to IndexedEntry keys.

See MutableEntryKey for more information.

§

type Key = K

source§

impl<K, V> MutableEntryKey for OccupiedEntry<'_, K, V>

Opt-in mutable access to OccupiedEntry keys.

See MutableEntryKey for more information.

§

type Key = K

source§

impl<K, V> MutableEntryKey for VacantEntry<'_, K, V>

Opt-in mutable access to VacantEntry keys.

See MutableEntryKey for more information.

§

type Key = K