pub struct Map<K: Obj, V: Obj>(/* private fields */);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 map, Some(v) is returned.
Otherwise, None 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.
Trait Implementations§
Source§impl<K: Obj, V: Obj> FromIterator<(K, V)> for Map<K, V>
impl<K: Obj, V: Obj> FromIterator<(K, V)> for Map<K, V>
Source§impl<K: Obj, V: Obj> IntoIterator for Map<K, V>
impl<K: Obj, V: Obj> IntoIterator for Map<K, V>
impl<K: Copy + Obj, V: Copy + Obj> Copy for Map<K, V>
impl<K: Eq + Obj, V: Eq + Obj> Eq for Map<K, V>
impl<K: Obj, V: Obj> StructuralPartialEq for Map<K, V>
Auto Trait Implementations§
impl<K, V> Freeze for Map<K, V>
impl<K, V> RefUnwindSafe for Map<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> !Send for Map<K, V>
impl<K, V> !Sync for Map<K, V>
impl<K, V> Unpin for Map<K, V>
impl<K, V> UnwindSafe for Map<K, V>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more