Skip to main content

StoreIterableMut

Trait StoreIterableMut 

Source
pub trait StoreIterableMut<K, V>: StoreMut<K, V>
where K: Key, V: Value,
{ type IterMut<'a>: Iterator<Item = (&'a K, &'a mut V)> where Self: 'a; // Required method fn iter_mut(&mut self) -> Self::IterMut<'_>; }
Expand description

Mutable store that is iterable.

This trait extends StoreMut, adding mutable iteration capabilities as a requirement, so a store can enumerate its items mutably.

§Examples

use std::collections::HashMap;
use zrx_store::{StoreIterableMut, 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_mut() {
    println!("{key}: {value}");
}

Required Associated Types§

Source

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

Required Methods§

Source

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

Creates a mutable 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> StoreIterableMut<K, V> for BTreeMap<K, V>
where K: Key, V: Value,

Source§

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

Creates a mutable iterator over the items of the store.

§Examples
use std::collections::BTreeMap;
use zrx_store::{StoreIterableMut, 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_mut() {
    println!("{key}: {value}");
}
Source§

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

Source§

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

Source§

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

Creates a mutable iterator over the items of the store.

§Examples
use slab::Slab;
use zrx_store::{StoreIterableMut, 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 StoreIterableMut::iter_mut(&mut store) {
    println!("{key}: {value}");
}
Source§

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

Source§

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

Source§

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

Creates a mutable iterator over the items of the store.

§Examples
use std::collections::HashMap;
use zrx_store::{StoreIterableMut, 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_mut() {
    println!("{key}: {value}");
}
Source§

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

Implementors§

Source§

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

Source§

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

Source§

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

Source§

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