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§
sourcefn expect_insert(&mut self, k: K, v: V, msg: &str)
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.
sourcefn expect_remove(&mut self, k: &K, msg: &str) -> V
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§
sourcefn unwrap_insert(&mut self, k: K, v: V)
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.
sourcefn unwrap_remove(&mut self, k: &K) -> V
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.