litemap::store

Trait StoreMut

Source
pub trait StoreMut<K, V>: Store<K, V> {
    // Required methods
    fn lm_with_capacity(capacity: usize) -> Self;
    fn lm_reserve(&mut self, additional: usize);
    fn lm_get_mut(&mut self, index: usize) -> Option<(&K, &mut V)>;
    fn lm_push(&mut self, key: K, value: V);
    fn lm_insert(&mut self, index: usize, key: K, value: V);
    fn lm_remove(&mut self, index: usize) -> (K, V);
    fn lm_clear(&mut self);

    // Provided method
    fn lm_retain<F>(&mut self, predicate: F)
       where F: FnMut(&K, &V) -> bool { ... }
}

Required Methods§

Source

fn lm_with_capacity(capacity: usize) -> Self

Creates a new store with the specified capacity hint.

Implementations may ignore the argument if they do not support pre-allocating capacity.

Source

fn lm_reserve(&mut self, additional: usize)

Reserves additional capacity in the store.

Implementations may ignore the argument if they do not support pre-allocating capacity.

Source

fn lm_get_mut(&mut self, index: usize) -> Option<(&K, &mut V)>

Gets a key/value pair at the specified index, with a mutable value.

Source

fn lm_push(&mut self, key: K, value: V)

Pushes one additional item onto the store.

Source

fn lm_insert(&mut self, index: usize, key: K, value: V)

Inserts an item at a specific index in the store.

§Panics

Panics if index is greater than the length.

Source

fn lm_remove(&mut self, index: usize) -> (K, V)

Removes an item at a specific index in the store.

§Panics

Panics if index is greater than the length.

Source

fn lm_clear(&mut self)

Removes all items from the store.

Provided Methods§

Source

fn lm_retain<F>(&mut self, predicate: F)
where F: FnMut(&K, &V) -> bool,

Retains items satisfying a predicate in this store.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<K, V> StoreMut<K, V> for Vec<(K, V)>

Source§

fn lm_with_capacity(capacity: usize) -> Self

Source§

fn lm_reserve(&mut self, additional: usize)

Source§

fn lm_get_mut(&mut self, index: usize) -> Option<(&K, &mut V)>

Source§

fn lm_push(&mut self, key: K, value: V)

Source§

fn lm_insert(&mut self, index: usize, key: K, value: V)

Source§

fn lm_remove(&mut self, index: usize) -> (K, V)

Source§

fn lm_clear(&mut self)

Source§

fn lm_retain<F>(&mut self, predicate: F)
where F: FnMut(&K, &V) -> bool,

Implementors§