Skip to main content

StoreValues

Trait StoreValues 

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

Immutable store that is iterable over its values.

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

§Examples

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

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

// Create iterator over the store
for value in store.values() {
    println!("{value}");
}

Required Associated Types§

Source

type Values<'a>: Iterator<Item = &'a V> where Self: 'a

Required Methods§

Source

fn values(&self) -> Self::Values<'_>

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

Source§

fn values(&self) -> Self::Values<'_>

Creates an iterator over the values of the store.

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

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

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

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

Source§

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

Source§

fn values(&self) -> Self::Values<'_>

Creates an iterator over the values of the store.

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

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

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

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

Source§

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

Source§

fn values(&self) -> Self::Values<'_>

Creates an iterator over the values of the store.

§Examples
use std::collections::HashMap;
use zrx_store::{StoreMut, StoreValues};

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

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

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

Implementors§

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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