pub struct Map<K: Obj, V: Obj>(_);Expand description
Garbage-collected hash map implementing Copy.
Implementations§
source§impl<K: Obj, V: Obj> Map<K, V>
impl<K: Obj, V: Obj> Map<K, V>
sourcepub fn get(&self, k: K) -> Option<V>
pub fn get(&self, k: K) -> Option<V>
Returns the value to the key k.
Returns None if the key k is not in the Map.
sourcepub fn index_at(&self, k: K) -> V
pub fn index_at(&self, k: K) -> V
The indexing operator:
specr translates a[b] to a.index_at(b).
sourcepub fn remove(&mut self, k: K) -> Option<V>
pub fn remove(&mut self, k: K) -> Option<V>
Removes k from the map.
If the pair (k, v)was in the mapSome(v)is returned. OtherwiseNone` is returned.
sourcepub fn contains_key(&self, k: K) -> bool
pub fn contains_key(&self, k: K) -> bool
Checks whether self contains k.
sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
pub fn insert(&mut self, k: K, v: V) -> Option<V>
Insert a key/value mapping into a map. If the map already has a mapping for the given key the previous value is overwritten.
sourcepub fn try_insert(&mut self, k: K, v: V) -> Result<(), ()>
pub fn try_insert(&mut self, k: K, v: V) -> Result<(), ()>
Like insert, but fails if k was already in the map.