pub trait StoreIterable<K, V>: Store<K, V>{
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§
Required Methods§
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>
impl<K, V> StoreIterable<K, V> for BTreeMap<K, V>
Source§fn iter(&self) -> Self::Iter<'_>
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}");
}type Iter<'a> = Iter<'a, K, V> where Self: 'a
Source§impl<K, V> StoreIterable<K, V> for Slab<(K, V)>
impl<K, V> StoreIterable<K, V> for Slab<(K, V)>
Source§fn iter(&self) -> Self::Iter<'_>
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}");
}type Iter<'a> = Iter<'a, K, V> where Self: 'a
Source§impl<K, V, S> StoreIterable<K, V> for HashMap<K, V, S>
impl<K, V, S> StoreIterable<K, V> for HashMap<K, V, S>
Source§fn iter(&self) -> Self::Iter<'_>
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}");
}