Skip to main content

StoreKeys

Trait StoreKeys 

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

Immutable store that is iterable over its keys.

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

§Examples

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

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

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

Required Associated Types§

Source

type Keys<'a>: Iterator<Item = &'a K> where Self: 'a

Required Methods§

Source

fn keys(&self) -> Self::Keys<'_>

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

Source§

fn keys(&self) -> Self::Keys<'_>

Creates an iterator over the keys of the store.

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

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

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

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

Source§

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

Source§

fn keys(&self) -> Self::Keys<'_>

Creates an iterator over the keys of the store.

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

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

Source§

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

Source§

fn keys(&self) -> Self::Keys<'_>

Creates an iterator over the keys of the store.

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

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

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

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

Implementors§

Source§

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

Source§

type Keys<'a> = Keys<'a, K> where Self: 'a

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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