Trait splitmut::SplitMut

source ·
pub trait SplitMut<K, V> {
    // Required methods
    fn get1_mut(&mut self, k1: K) -> Option<&mut V>;
    unsafe fn get1_unchecked_mut(&mut self, k1: K) -> &mut V;

    // Provided methods
    fn get2_mut(
        &mut self,
        k1: K,
        k2: K,
    ) -> (Result<&mut V, SplitMutError>, Result<&mut V, SplitMutError>) { ... }
    fn get3_mut(
        &mut self,
        k1: K,
        k2: K,
        k3: K,
    ) -> (Result<&mut V, SplitMutError>, Result<&mut V, SplitMutError>, Result<&mut V, SplitMutError>) { ... }
    fn get4_mut(
        &mut self,
        k1: K,
        k2: K,
        k3: K,
        k4: K,
    ) -> (Result<&mut V, SplitMutError>, Result<&mut V, SplitMutError>, Result<&mut V, SplitMutError>, Result<&mut V, SplitMutError>) { ... }
    unsafe fn get2_unchecked_mut(&mut self, k1: K, k2: K) -> (&mut V, &mut V) { ... }
    unsafe fn get3_unchecked_mut(
        &mut self,
        k1: K,
        k2: K,
        k3: K,
    ) -> (&mut V, &mut V, &mut V) { ... }
    unsafe fn get4_unchecked_mut(
        &mut self,
        k1: K,
        k2: K,
        k3: K,
        k4: K,
    ) -> (&mut V, &mut V, &mut V, &mut V) { ... }
}
Expand description

Just add use splitmut::SplitMut; to have these methods working on mutable slices, Vec, VecDeque, HashMap and BTreeMap.

In case you want to implement SplitMut for your own collection, just implement get1_mut and get1_unchecked_mut and the other methods will be provided for you.

Required Methods§

source

fn get1_mut(&mut self, k1: K) -> Option<&mut V>

Wrapper for get_mut, used internally.

source

unsafe fn get1_unchecked_mut(&mut self, k1: K) -> &mut V

Wrapper for get_unchecked_mut, used internally.

§Undefined behaviour

It is undefined behaviour to call this with a key that does not correspond to a value. You have been warned.

Provided Methods§

source

fn get2_mut( &mut self, k1: K, k2: K, ) -> (Result<&mut V, SplitMutError>, Result<&mut V, SplitMutError>)

Returns two mutable references to two distinct values within the same collection.

source

fn get3_mut( &mut self, k1: K, k2: K, k3: K, ) -> (Result<&mut V, SplitMutError>, Result<&mut V, SplitMutError>, Result<&mut V, SplitMutError>)

Returns three mutable references to three distinct values within the same collection.

source

fn get4_mut( &mut self, k1: K, k2: K, k3: K, k4: K, ) -> (Result<&mut V, SplitMutError>, Result<&mut V, SplitMutError>, Result<&mut V, SplitMutError>, Result<&mut V, SplitMutError>)

Returns four mutable references to four distinct values within the same collection.

source

unsafe fn get2_unchecked_mut(&mut self, k1: K, k2: K) -> (&mut V, &mut V)

Returns two mutable references to two distinct values within the same collection.

§Undefined behaviour

It is undefined behaviour to call this with a key that does not correspond to a value, or with keys pointing to the same value. You have been warned.

source

unsafe fn get3_unchecked_mut( &mut self, k1: K, k2: K, k3: K, ) -> (&mut V, &mut V, &mut V)

Returns three mutable references to three distinct values within the same collection.

§Undefined behaviour

It is undefined behaviour to call this with a key that does not correspond to a value, or with any two keys pointing to the same value. You have been warned.

source

unsafe fn get4_unchecked_mut( &mut self, k1: K, k2: K, k3: K, k4: K, ) -> (&mut V, &mut V, &mut V, &mut V)

Returns four mutable references to four distinct values within the same collection.

§Undefined behaviour

It is undefined behaviour to call this with a key that does not correspond to a value, or with any two keys pointing to the same value. You have been warned.

Implementations on Foreign Types§

source§

impl<'a, K: Ord, V> SplitMut<&'a K, V> for BTreeMap<K, V>

source§

fn get1_mut(&mut self, k: &'a K) -> Option<&mut V>

source§

unsafe fn get1_unchecked_mut(&mut self, k: &'a K) -> &mut V

source§

impl<'a, K: Hash + Eq, V> SplitMut<&'a K, V> for HashMap<K, V>

source§

fn get1_mut(&mut self, k: &'a K) -> Option<&mut V>

source§

unsafe fn get1_unchecked_mut(&mut self, k: &'a K) -> &mut V

source§

impl<'a, V> SplitMut<usize, V> for &'a mut [V]

source§

fn get1_mut(&mut self, k: usize) -> Option<&mut V>

source§

unsafe fn get1_unchecked_mut(&mut self, k: usize) -> &mut V

source§

impl<'a, V> SplitMut<usize, V> for VecDeque<V>

source§

fn get1_mut(&mut self, k: usize) -> Option<&mut V>

source§

unsafe fn get1_unchecked_mut(&mut self, k: usize) -> &mut V

source§

impl<'a, V> SplitMut<usize, V> for Vec<V>

source§

fn get1_mut(&mut self, k: usize) -> Option<&mut V>

source§

unsafe fn get1_unchecked_mut(&mut self, k: usize) -> &mut V

Implementors§