Trait protocoll::Map
[−]
[src]
pub trait Map<K, V> where Self: Sized { fn fun<'a, Q: ?Sized>(&'a self) -> Box<Fn(&Q) -> Option<&'a V> + 'a> where K: Borrow<Q>, Q: Hash + Ord; fn inc(self, kv: (K, V)) -> Self; fn dec<Q: ?Sized>(self, k: &Q) -> Self where K: Borrow<Q>, Q: Hash + Ord; fn zero(self) -> Self; fn shrink(self) -> Self; fn update<F>(self, k: K, f: F) -> Self where F: FnOnce(Option<V>) -> V; fn plus<I>(self, coll: I) -> Self where I: IntoIterator<Item=(K, V)> { ... } fn merge<M, F>(self, other: M, f: F) -> Self where M: IntoIterator<Item=(K, V)>, F: FnMut(V, V) -> V { ... } }
basic protocol for maps.
Required Methods
fn fun<'a, Q: ?Sized>(&'a self) -> Box<Fn(&Q) -> Option<&'a V> + 'a> where K: Borrow<Q>, Q: Hash + Ord
a map maps from keys to values.
fn inc(self, kv: (K, V)) -> Self
adds entry kv
.
fn dec<Q: ?Sized>(self, k: &Q) -> Self where K: Borrow<Q>, Q: Hash + Ord
removes key k
.
fn zero(self) -> Self
clear
.
fn shrink(self) -> Self
shrink_to_fit
.
fn update<F>(self, k: K, f: F) -> Self where F: FnOnce(Option<V>) -> V
like clojure's update.
Provided Methods
fn plus<I>(self, coll: I) -> Self where I: IntoIterator<Item=(K, V)>
pours another collection into this one.
fn merge<M, F>(self, other: M, f: F) -> Self where M: IntoIterator<Item=(K, V)>, F: FnMut(V, V) -> V
like clojure's merge-with.