Skip to main content

StoreWithComparator

Trait StoreWithComparator 

Source
pub trait StoreWithComparator<K, V, C>: Store<K, V>
where C: Comparator<V>,
{ // Required method fn with_comparator(comparator: C) -> Self; }
Expand description

Creates a store with a comparator.

This trait extends Store, adding the capability to create a store with a custom comparator, allowing to customize the ordering of values.

§Examples

use std::collections::HashMap;
use zrx_store::comparator::Descending;
use zrx_store::decorator::Ordered;
use zrx_store::{StoreMut, StoreWithComparator};

// Create store
let mut store: Ordered::<_, _, HashMap<_, _>, _> =
    Ordered::with_comparator(Descending);

// Insert value
store.insert("key", 42);

Required Methods§

Source

fn with_comparator(comparator: C) -> Self

Creates a store with the given comparator.

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.

Implementors§

Source§

impl<K, V, S, C> StoreWithComparator<K, V, C> for Indexed<K, V, S, C>
where K: Key, S: Store<K, V> + Default, C: Comparator<V>,

Source§

impl<K, V, S, C> StoreWithComparator<K, V, C> for Ordered<K, V, S, C>
where K: Key, S: Store<K, V> + Default, C: Comparator<V>,