miden_crypto::utils::collections

Trait KvMap

source
pub trait KvMap<K: Ord + Clone, V: Clone>:
    Extend<(K, V)>
    + FromIterator<(K, V)>
    + IntoIterator<Item = (K, V)> {
    // Required methods
    fn get(&self, key: &K) -> Option<&V>;
    fn contains_key(&self, key: &K) -> bool;
    fn len(&self) -> usize;
    fn insert(&mut self, key: K, value: V) -> Option<V>;
    fn remove(&mut self, key: &K) -> Option<V>;
    fn iter(&self) -> Box<dyn Iterator<Item = (&K, &V)> + '_>;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

A trait that defines the interface for a key-value map.

Required Methods§

source

fn get(&self, key: &K) -> Option<&V>

source

fn contains_key(&self, key: &K) -> bool

source

fn len(&self) -> usize

source

fn insert(&mut self, key: K, value: V) -> Option<V>

source

fn remove(&mut self, key: &K) -> Option<V>

source

fn iter(&self) -> Box<dyn Iterator<Item = (&K, &V)> + '_>

Provided Methods§

source

fn is_empty(&self) -> bool

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: Ord + Clone, V: Clone> KvMap<K, V> for BTreeMap<K, V>

source§

fn get(&self, key: &K) -> Option<&V>

source§

fn contains_key(&self, key: &K) -> bool

source§

fn len(&self) -> usize

source§

fn insert(&mut self, key: K, value: V) -> Option<V>

source§

fn remove(&mut self, key: &K) -> Option<V>

source§

fn iter(&self) -> Box<dyn Iterator<Item = (&K, &V)> + '_>

Implementors§

source§

impl<K: Ord + Clone, V: Clone> KvMap<K, V> for RecordingMap<K, V>