Skip to main content

StoreIterable

Trait StoreIterable 

Source
pub trait StoreIterable<K, V>: Store<K, V>
where K: Key, V: Value,
{ type Iter<'a>: Iterator<Item = (&'a K, &'a V)> where Self: 'a; // Required method fn iter(&self) -> Self::Iter<'_>; }
Expand description

Immutable store that is iterable.

This trait extends Store, adding iteration capabilities as a further requirement, so a store can enumerate its items.

§Examples

use std::collections::HashMap;
use zrx_store::{StoreIterable, StoreMut};

// Create store and initial state
let mut store = HashMap::new();
store.insert("key", 42);

// Create iterator over the store
for (key, value) in store.iter() {
    println!("{key}: {value}");
}

Required Associated Types§

Source

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

Required Methods§

Source

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

Creates an iterator over the items of the 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> StoreIterable<K, V> for BTreeMap<K, V>
where K: Key, V: Value,

Source§

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

Creates an iterator over the items of the store.

§Examples
use std::collections::BTreeMap;
use zrx_store::{StoreIterable, StoreMut};

// Create store and initial state
let mut store = BTreeMap::new();
store.insert("key", 42);

// Create iterator over the store
for (key, value) in store.iter() {
    println!("{key}: {value}");
}
Source§

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

Source§

impl<K, V> StoreIterable<K, V> for Slab<(K, V)>
where K: Key, V: Value,

Source§

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

Creates an iterator over the items of the store.

§Examples
use slab::Slab;
use zrx_store::{StoreIterable, StoreMut};

// Create store and initial state
let mut store = Slab::new();
StoreMut::insert(&mut store, "key", 42);

// Create iterator over the store
for (key, value) in StoreIterable::iter(&store) {
    println!("{key}: {value}");
}
Source§

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

Source§

impl<K, V, S> StoreIterable<K, V> for HashMap<K, V, S>
where K: Key, V: Value, S: BuildHasher,

Source§

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

Creates an iterator over the items of the store.

§Examples
use std::collections::HashMap;
use zrx_store::StoreMut;

// Create store and initial state
let mut store = HashMap::new();
store.insert("key", 42);

// Create iterator over the store
for (key, value) in store {
    println!("{key}: {value}");
}
Source§

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

Implementors§

Source§

impl<K, V, S> StoreIterable<K, V> for Queue<K, V, S>
where K: Key, V: Value, S: StoreIterable<K, Item>,

Source§

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

Source§

impl<K, V, S> StoreIterable<K, V> for Stash<K, V, S>
where K: Key, V: Value, S: StoreIterable<K, usize>,

Source§

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

Source§

impl<K, V, S, C> StoreIterable<K, V> for Indexed<K, V, S, C>
where K: Key, V: Value, S: Store<K, V>,

Source§

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

Source§

impl<K, V, S, C> StoreIterable<K, V> for Ordered<K, V, S, C>
where K: Key, V: Value, S: Store<K, V>,

Source§

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