Trait mz_ore::collections::AssociativeExt

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

    // Provided methods
    fn unwrap_insert(&mut self, k: K, v: V) { ... }
    fn unwrap_remove(&mut self, k: &K) -> 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.

source

fn expect_remove(&mut self, k: &K, msg: &str) -> V

Removes a key, panicking with a given message if a true removal (as opposed to a no-op) cannot be done because the key does not exist 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.

source

fn unwrap_remove(&mut self, k: &K) -> V

Removes a key, panicking if a true removal (as opposed to a no-op) cannot be done because the key does not exist 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)

source§

fn expect_remove(&mut self, k: &K, msg: &str) -> V

Implementors§

source§

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