Trait mz_ore::collections::AssociativeExt

source ·
pub trait AssociativeExt<K, V> {
    // Required method
    fn expect_insert(&mut self, k: K, v: V, msg: &str);

    // Provided method
    fn unwrap_insert(&mut self, k: K, v: V) { ... }
}
Expand description

Extension methods for associative collections.

Required Methods§

source

fn expect_insert(&mut self, k: K, v: V, msg: &str)

Inserts a key and value, panicking with a given message if a true insert (as opposed to an update) cannot be done because the key already existed in the collection.

Provided Methods§

source

fn unwrap_insert(&mut self, k: K, v: V)

Inserts a key and value, panicking if a true insert (as opposed to an update) cannot be done because the key already existed in the collection.

Implementations on Foreign Types§

source§

impl<K, V> AssociativeExt<K, V> for BTreeMap<K, V>
where K: Ord + Debug, V: Debug,

source§

fn expect_insert(&mut self, k: K, v: V, msg: &str)

Implementors§

source§

impl<K, V> AssociativeExt<K, V> for HashMap<K, V>
where K: Eq + Hash + Debug, V: Debug,