Struct Map
pub struct Map<K, V>(pub(crate) GcCow<HashMap<K, V>>)
where
K: Obj,
V: Obj;Expand description
Garbage-collected hash map implementing Copy.
This implements Ord but the order is not meaningful; this is just so one can use BTreeMaps.
In particular, the order might differ across two runs of the same program.
Tuple Fields§
§0: GcCow<HashMap<K, V>>Implementations§
§impl<K, V> Map<K, V>where
K: Obj,
V: Obj,
impl<K, V> Map<K, V>where
K: Obj,
V: Obj,
pub 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.
pub 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).
pub 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.
pub fn contains_key(&self, k: K) -> bool
pub fn contains_key(&self, k: K) -> bool
Checks whether self contains k.
pub 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.
pub 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§
impl<K, V> Copy for Map<K, V>
§impl<'de, K, V> Deserialize<'de> for Map<K, V>where
K: Obj + Deserialize<'de>,
V: Obj + Deserialize<'de>,
impl<'de, K, V> Deserialize<'de> for Map<K, V>where
K: Obj + Deserialize<'de>,
V: Obj + Deserialize<'de>,
§fn deserialize<D>(
deserializer: D,
) -> Result<Map<K, V>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Map<K, V>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<K, V> Eq for Map<K, V>
§impl<K, V> FromIterator<(K, V)> for Map<K, V>where
K: Obj,
V: Obj,
impl<K, V> FromIterator<(K, V)> for Map<K, V>where
K: Obj,
V: Obj,
§impl<K, V> IntoIterator for Map<K, V>where
K: Obj,
V: Obj,
impl<K, V> IntoIterator for Map<K, V>where
K: Obj,
V: Obj,
§impl<K, V> Ord for Map<K, V>
impl<K, V> Ord for Map<K, V>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
§impl<K, V> PartialOrd for Map<K, V>where
K: PartialOrd + Obj,
V: PartialOrd + Obj,
impl<K, V> PartialOrd for Map<K, V>where
K: PartialOrd + Obj,
V: PartialOrd + Obj,
§impl<K, V> Serialize for Map<K, V>
impl<K, V> Serialize for Map<K, V>
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<K, V> StructuralPartialEq for Map<K, V>
Auto Trait Implementations§
impl<K, V> !Send for Map<K, V>
impl<K, V> !Sync for Map<K, V>
impl<K, V> Freeze for Map<K, V>
impl<K, V> RefUnwindSafe for Map<K, V>where
GcCow<HashMap<K, V>>: RefUnwindSafe,
impl<K, V> Unpin for Map<K, V>
impl<K, V> UnsafeUnpin for Map<K, V>where
GcCow<HashMap<K, V>>: UnsafeUnpin,
impl<K, V> UnwindSafe for Map<K, V>where
GcCow<HashMap<K, V>>: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more