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
sourceimpl<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: ?Sized>(&self, k: &Q) -> Option<&V>where
K: Borrow<Q>,
Q: Eq,
pub fn get<Q: ?Sized>(&self, k: &Q) -> Option<&V>where
K: Borrow<Q>,
Q: Eq,
Gets a reference to the value in the entry.
sourcepub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V>where
K: Borrow<Q>,
Q: Eq,
pub fn get_mut<Q: ?Sized>(&mut self, k: &Q) -> Option<&mut V>where
K: Borrow<Q>,
Q: Eq,
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: ?Sized>(&self, k: &Q) -> boolwhere
K: Borrow<Q>,
Q: Eq,
pub fn contains_key<Q: ?Sized>(&self, k: &Q) -> boolwhere
K: Borrow<Q>,
Q: Eq,
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)>ⓘNotable traits for Iter<'a, T>impl<'a, T> Iterator for Iter<'a, T> type Item = &'a T;
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
sourceimpl<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>,
sourceimpl<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>,
sourceimpl<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>
sourcefn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I)
sourcefn extend_one(&mut self, (k, v): (K, V))
fn extend_one(&mut self, (k, v): (K, V))
extend_one
)sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)sourceimpl<K, V> FromIterator<(K, V)> for VecMap<K, V>
impl<K, V> FromIterator<(K, V)> for VecMap<K, V>
sourcefn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self
fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self
sourceimpl<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)
sourceimpl<'a, K, V> IntoIterator for &'a VecMap<K, V>
impl<'a, K, V> IntoIterator for &'a VecMap<K, V>
sourceimpl<'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
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
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