pub trait BackingContainer<K, V>: Default {
    type Iter<'a>: Iterator<Item = (K, &'a V)>
       where V: 'a,
             Self: 'a;

    // Required methods
    fn insert(&mut self, k: K, v: V);
    fn get(&self, k: &K) -> Option<&V>;
    fn get_mut(&mut self, k: &K) -> Option<&mut V>;
    fn remove(&mut self, k: &K);
    fn iter(&self) -> Self::Iter<'_>;
    fn len(&self) -> usize;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Trait for containers that can be wrapped using GroupingContainer.

Required Associated Types§

source

type Iter<'a>: Iterator<Item = (K, &'a V)> where V: 'a, Self: 'a

Type of iterator returned by the BackingContainer::iter method.

Required Methods§

source

fn insert(&mut self, k: K, v: V)

Set the value at the provided key.

source

fn get(&self, k: &K) -> Option<&V>

Get a reference to the value at the provided key, or None if the value doesn’t exist.

source

fn get_mut(&mut self, k: &K) -> Option<&mut V>

Get mutable a reference to the value at the provided key, or None if the value doesn’t exist.

source

fn remove(&mut self, k: &K)

Remove a value with the provided key, if it exists.

source

fn iter(&self) -> Self::Iter<'_>

Iterate over all (key, value) tuples in the container.

source

fn len(&self) -> usize

Return the number of elements in the container.

Provided Methods§

source

fn is_empty(&self) -> bool

Return whether the container is empty.

Implementations on Foreign Types§

source§

impl<V> BackingContainer<usize, V> for Vec<Option<V>>

source§

fn insert(&mut self, k: usize, v: V)

source§

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

source§

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

source§

fn remove(&mut self, k: &usize)

§

type Iter<'a> = FilterMap<Enumerate<Iter<'a, Option<V>>>, fn(_: (usize, &'a Option<V>)) -> Option<(usize, &'a V)>> where V: 'a

source§

fn iter(&self) -> Self::Iter<'_>

source§

fn len(&self) -> usize

source§

impl<K: Eq + Hash + Clone, V> BackingContainer<K, V> for HashMap<K, V>

source§

fn insert(&mut self, k: K, v: V)

source§

fn get(&self, k: &K) -> Option<&V>

source§

fn get_mut(&mut self, k: &K) -> Option<&mut V>

source§

fn remove(&mut self, k: &K)

§

type Iter<'a> = Map<Iter<'a, K, V>, fn(_: (&'a K, &'a V)) -> (K, &'a V)> where K: 'a, V: 'a

source§

fn iter(&self) -> Self::Iter<'_>

source§

fn len(&self) -> usize

Implementors§