Struct rustc_data_structures::vec_map::VecMap
source · Expand description
A map type implemented as a vector of pairs K
(key) and V
(value).
It currently provides a subset of all the map operations, the rest could be added as needed.
Tuple Fields§
§0: Vec<(K, V)>
Implementations§
source§impl<K, V> VecMap<K, V>where
K: Debug + PartialEq,
V: Debug,
impl<K, V> VecMap<K, V>where
K: Debug + PartialEq,
V: Debug,
pub fn new() -> Self
sourcepub fn insert(&mut self, k: K, v: V) -> Option<V>
pub fn insert(&mut self, k: K, v: V) -> Option<V>
Sets the value of the entry, and returns the entry’s old value.
sourcepub fn remove(&mut self, k: &K) -> Option<V>
pub fn remove(&mut self, k: &K) -> Option<V>
Removes the entry from the map and returns the removed value
sourcepub fn get<Q>(&self, k: &Q) -> Option<&V>where
K: Borrow<Q>,
Q: Eq + ?Sized,
pub fn get<Q>(&self, k: &Q) -> Option<&V>where
K: Borrow<Q>,
Q: Eq + ?Sized,
Gets a reference to the value in the entry.
sourcepub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>where
K: Borrow<Q>,
Q: Eq + ?Sized,
pub fn get_mut<Q>(&mut self, k: &Q) -> Option<&mut V>where
K: Borrow<Q>,
Q: Eq + ?Sized,
Gets a mutable reference to the value in the entry.
sourcepub fn any_value_matching(
&self,
predicate: impl FnMut(&(K, V)) -> bool
) -> Option<&V>
pub fn any_value_matching(
&self,
predicate: impl FnMut(&(K, V)) -> bool
) -> Option<&V>
Returns the any value corresponding to the supplied predicate filter.
The supplied predicate will be applied to each (key, value) pair and it will return a
reference to the values where the predicate returns true
.
sourcepub fn get_value_matching(
&self,
predicate: impl FnMut(&(K, V)) -> bool
) -> Option<&V>
pub fn get_value_matching(
&self,
predicate: impl FnMut(&(K, V)) -> bool
) -> Option<&V>
Returns the value corresponding to the supplied predicate filter. It crashes if there’s more than one matching element.
The supplied predicate will be applied to each (key, value) pair and it will return a
reference to the value where the predicate returns true
.
sourcepub fn contains_key<Q>(&self, k: &Q) -> boolwhere
K: Borrow<Q>,
Q: Eq + ?Sized,
pub fn contains_key<Q>(&self, k: &Q) -> boolwhere
K: Borrow<Q>,
Q: Eq + ?Sized,
Returns true
if the map contains a value for the specified key.
The key may be any borrowed form of the map’s key type,
Eq
on the borrowed form must match those for
the key type.
pub fn iter(&self) -> Iter<'_, (K, V)> ⓘ
pub fn iter_mut(&mut self) -> impl Iterator<Item = (&K, &mut V)>
pub fn retain(&mut self, f: impl Fn(&(K, V)) -> bool)
Trait Implementations§
source§impl<K, V, __D: Decoder> Decodable<__D> for VecMap<K, V>where
K: Decodable<__D>,
V: Decodable<__D>,
impl<K, V, __D: Decoder> Decodable<__D> for VecMap<K, V>where
K: Decodable<__D>,
V: Decodable<__D>,
source§impl<K, V, __E: Encoder> Encodable<__E> for VecMap<K, V>where
K: Encodable<__E>,
V: Encodable<__E>,
impl<K, V, __E: Encoder> Encodable<__E> for VecMap<K, V>where
K: Encodable<__E>,
V: Encodable<__E>,
source§impl<K: PartialEq + Debug, V: Debug> Extend<(K, V)> for VecMap<K, V>
impl<K: PartialEq + Debug, V: Debug> Extend<(K, V)> for VecMap<K, V>
source§fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
source§fn extend_one(&mut self, (k, v): (K, V))
fn extend_one(&mut self, (k, v): (K, V))
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl<K, V> FromIterator<(K, V)> for VecMap<K, V>
impl<K, V> FromIterator<(K, V)> for VecMap<K, V>
source§impl<K, V, CTX> HashStable<CTX> for VecMap<K, V>where
K: HashStable<CTX> + Eq,
V: HashStable<CTX>,
impl<K, V, CTX> HashStable<CTX> for VecMap<K, V>where
K: HashStable<CTX> + Eq,
V: HashStable<CTX>,
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher)
source§impl<'a, K, V> IntoIterator for &'a VecMap<K, V>
impl<'a, K, V> IntoIterator for &'a VecMap<K, V>
source§impl<'a, K: 'a, V: 'a> IntoIterator for &'a mut VecMap<K, V>
impl<'a, K: 'a, V: 'a> IntoIterator for &'a mut VecMap<K, V>
Auto Trait Implementations§
impl<K, V> RefUnwindSafe for VecMap<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for VecMap<K, V>where
K: Send,
V: Send,
impl<K, V> Sync for VecMap<K, V>where
K: Sync,
V: Sync,
impl<K, V> Unpin for VecMap<K, V>where
K: Unpin,
V: Unpin,
impl<K, V> UnwindSafe for VecMap<K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> Erased for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 24 bytes