pub trait StoreRange<K, V>: Store<K, V>{
type Range<'a>: Iterator<Item = (&'a K, &'a V)>
where Self: 'a;
// Required method
fn range<R>(&self, range: R) -> Self::Range<'_>
where R: RangeBounds<K>;
}Expand description
Immutable store that is iterable over a range.
This trait extends Store, adding iteration capabilities as a further
requirement, so a store can enumerate its items over a given range.
§Examples
use std::collections::BTreeMap;
use zrx_store::{StoreMut, StoreRange};
// Create store and initial state
let mut store = BTreeMap::new();
store.insert("a", 42);
store.insert("b", 84);
// Create iterator over the store
for (key, value) in store.range("b"..) {
println!("{key}: {value}");
}Required Associated Types§
Required Methods§
Sourcefn range<R>(&self, range: R) -> Self::Range<'_>where
R: RangeBounds<K>,
fn range<R>(&self, range: R) -> Self::Range<'_>where
R: RangeBounds<K>,
Creates an iterator over a range of items of the store.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl<K, V> StoreRange<K, V> for BTreeMap<K, V>
impl<K, V> StoreRange<K, V> for BTreeMap<K, V>
Source§fn range<R>(&self, range: R) -> <BTreeMap<K, V> as StoreRange<K, V>>::Range<'_>where
R: RangeBounds<K>,
fn range<R>(&self, range: R) -> <BTreeMap<K, V> as StoreRange<K, V>>::Range<'_>where
R: RangeBounds<K>,
Creates an iterator over a range of items in a store.
§Examples
use std::collections::BTreeMap;
use zrx_store::{StoreMut, StoreRange};
// Create store and initial state
let mut store = BTreeMap::new();
store.insert("a", 42);
store.insert("b", 84);
// Create iterator over the store
for (key, value) in store.range("b"..) {
println!("{key}: {value}");
}