Skip to main content

IterableMap

Trait IterableMap 

Source
pub trait IterableMap<K, V>: BackingMap<K, V> {
    type Iter<'a>: Iterator<Item = (&'a K, &'a V)>
       where Self: 'a,
             K: 'a,
             V: 'a;
    type IterMut<'a>: Iterator<Item = (&'a K, &'a mut V)>
       where Self: 'a,
             K: 'a,
             V: 'a;

    // Required methods
    fn iter(&self) -> Self::Iter<'_>;
    fn iter_mut(&mut self) -> Self::IterMut<'_>;
}
Expand description

Extension trait for backing maps that support iteration.

This trait is required when using unknown/extension fields with #[structible(key = ...)]. It provides iter() and iter_mut() methods for iterating over entries in the map.

It is automatically implemented for HashMap and BTreeMap.

Required Associated Types§

Source

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

Iterator type for immutable iteration.

Source

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

Iterator type for mutable iteration.

Required Methods§

Source

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

Returns an iterator over all key-value pairs.

Source

fn iter_mut(&mut self) -> Self::IterMut<'_>

Returns a mutable iterator over all key-value pairs.

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> IterableMap<K, V> for BTreeMap<K, V>
where K: Ord,

Source§

type Iter<'a> = Iter<'a, K, V> where K: 'a, V: 'a

Source§

type IterMut<'a> = IterMut<'a, K, V> where K: 'a, V: 'a

Source§

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

Source§

fn iter_mut(&mut self) -> Self::IterMut<'_>

Source§

impl<K, V> IterableMap<K, V> for HashMap<K, V>
where K: Eq + Hash,

Source§

type Iter<'a> = Iter<'a, K, V> where K: 'a, V: 'a

Source§

type IterMut<'a> = IterMut<'a, K, V> where K: 'a, V: 'a

Source§

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

Source§

fn iter_mut(&mut self) -> Self::IterMut<'_>

Implementors§