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§
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> StoreKeys<K, V> for BTreeMap<K, V>where
K: Key,
impl<K, V> StoreKeys<K, V> for BTreeMap<K, V>where
K: Key,
Source§fn keys(&self) -> Self::Keys<'_>
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}");
}type Keys<'a> = Keys<'a, K, V> where Self: 'a
Source§impl<K, V> StoreKeys<K, V> for Slab<(K, V)>where
K: Key,
impl<K, V> StoreKeys<K, V> for Slab<(K, V)>where
K: Key,
Source§fn keys(&self) -> Self::Keys<'_>
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}");
}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,
impl<K, V, S> StoreKeys<K, V> for HashMap<K, V, S>where
K: Key,
S: BuildHasher,
Source§fn keys(&self) -> Self::Keys<'_>
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}");
}