Skip to main content

AssociativeExt

Trait 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.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

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,