Trait eclectic::map::Base [] [src]

pub trait Base: Collection<Item=(Self::Key, Self::Value)> {
    type Key;
    type Value;
    fn iter<'a>(&'a self) -> Box<Iterator<Item=(&'a Self::Key, &'a Self::Value)> + 'a>;
    fn iter_mut<'a>(&'a mut self) -> Box<Iterator<Item=(&'a Self::Key, &'a mut Self::Value)> + 'a> where Self: Mut;
    fn insert(&mut self, key: Self::Key, value: Self::Value) -> Option<Self::Value> where Self: Own;
    fn entry<'a>(&'a mut self, key: Self::Key) -> Entry<'a, Self::Key, Self::Value> where Self: Own;
}

Map functionality that is independent of an additional type parameter.

It is unusual to use this trait directly. Consider using Map instead.

This trait exists to prevent compilation errors that would occur due to ambiguous method calls if the methods were instead implemented on Map<Q>. For example, calling insert on a Map<Q> should not depend on Q.

Associated Types

type Key

The type of the map's keys.

type Value

The type of the map's values.

Required Methods

fn iter<'a>(&'a self) -> Box<Iterator<Item=(&'a Self::Key, &'a Self::Value)> + 'a>

Returns an iterator that yields references to the map's keys and references to their values.

The iteration order is unspecified, but subtraits may place a requirement on it.

fn iter_mut<'a>(&'a mut self) -> Box<Iterator<Item=(&'a Self::Key, &'a mut Self::Value)> + 'a> where Self: Mut

Returns an iterator that yields references to the map's keys and mutable references to their values.

The iteration order is unspecified, but subtraits may place a requirement on it.

fn insert(&mut self, key: Self::Key, value: Self::Value) -> Option<Self::Value> where Self: Own

Inserts the given key and value into the map without replacing an equivalent key.

If the map contains a key that is equivalent to the given key, that key is not replaced with the given key. The value is always replaced, however.

Returns the equivalent key's value if the map contained one, None otherwise.

fn entry<'a>(&'a mut self, key: Self::Key) -> Entry<'a, Self::Key, Self::Value> where Self: Own

Returns the entry in the map for the given key.

Implementors