Trait HashMapExt

Source
pub trait HashMapExt<K, V> {
    // Required method
    fn try_insert_ext(
        &mut self,
        k: K,
        v: V,
    ) -> Option<(V, OccupiedEntry<'_, K, V>)>;
}
Expand description

Extension trait for HashMap<K, V>.

Required Methods§

Source

fn try_insert_ext(&mut self, k: K, v: V) -> Option<(V, OccupiedEntry<'_, K, V>)>

Like insert, but if the insertion fails then it returns the value that it attempted to insert, as well as an OccupiedEntry containing the other value that was found.

Implementations on Foreign Types§

Source§

impl<K: Hash + Eq, V, S: BuildHasher> HashMapExt<K, V> for HashMap<K, V, S>

Source§

fn try_insert_ext(&mut self, k: K, v: V) -> Option<(V, OccupiedEntry<'_, K, V>)>

Implementors§