[−][src]Struct map_vec::Map
vec_map::Map
is a data structure with a HashMap
-like API but based on a Vec
.
It's primarily useful when you care about constant factors or prefer determinism to speed.
Please refer to the docs for HashMap
for details and examples of the Map API.
Example
fn main() { let mut map = vec_map::Map::new(); map.insert("hello".to_string(), "world".to_string()); map.entry("hello".to_string()).and_modify(|mut v| v.push_str("!")); assert_eq!(map.get("hello").map(String::as_str), Some("world!")) }
Methods
impl<K: Eq, V> Map<K, V>
[src]
pub fn new() -> Self
[src]
pub fn with_capacity(capacity: usize) -> Self
[src]
pub fn capacity(&self) -> usize
[src]
pub fn clear(&mut self)
[src]
pub fn contains_key<Q: ?Sized>(&self, key: &Q) -> bool where
K: Borrow<Q>,
Q: Eq,
[src]
K: Borrow<Q>,
Q: Eq,
pub fn drain(&mut self) -> Drain<(K, V)>
[src]
pub fn entry(&mut self, key: K) -> Entry<K, V>
[src]
pub fn get<Q: ?Sized>(&self, key: &Q) -> Option<&V> where
K: Borrow<Q>,
Q: Eq,
[src]
K: Borrow<Q>,
Q: Eq,
pub fn get_key_value<Q: ?Sized>(&self, key: &Q) -> Option<(&K, &V)> where
K: Borrow<Q>,
Q: Eq,
[src]
K: Borrow<Q>,
Q: Eq,
pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V> where
K: Borrow<Q>,
Q: Eq,
[src]
K: Borrow<Q>,
Q: Eq,
pub fn insert(&mut self, key: K, value: V) -> Option<V>
[src]
pub fn is_empty(&self) -> bool
[src]
pub fn iter(&self) -> Map<Iter<(K, V)>, fn(_: &'a (K, V)) -> (&'a K, &'a V)>
[src]
pub fn iter_mut(
&mut self
) -> Map<IterMut<(K, V)>, fn(_: &'a mut (K, V)) -> (&'a mut K, &'a mut V)>
[src]
&mut self
) -> Map<IterMut<(K, V)>, fn(_: &'a mut (K, V)) -> (&'a mut K, &'a mut V)>
pub fn keys(&self) -> impl Iterator<Item = &K>
[src]
pub fn len(&self) -> usize
[src]
pub fn remove<Q: ?Sized>(&mut self, key: &Q) -> Option<V> where
K: Borrow<Q>,
Q: Eq,
[src]
K: Borrow<Q>,
Q: Eq,
pub fn remove_entry<Q: ?Sized>(&mut self, key: &Q) -> Option<(K, V)> where
K: Borrow<Q>,
Q: Eq,
[src]
K: Borrow<Q>,
Q: Eq,
pub fn reserve(&mut self, additional: usize)
[src]
pub fn retain(&mut self, f: impl FnMut(&K, &mut V) -> bool)
[src]
pub fn shrink_to(&mut self, min_capacity: usize)
[src]
pub fn shrink_to_fit(&mut self)
[src]
pub fn try_reserve(
&mut self,
additional: usize
) -> Result<(), CollectionAllocErr>
[src]
&mut self,
additional: usize
) -> Result<(), CollectionAllocErr>
pub fn values(&self) -> impl Iterator<Item = &V>
[src]
pub fn values_mut(&mut self) -> impl Iterator<Item = &mut V>
[src]
Trait Implementations
impl<K: Debug, V: Debug> Debug for Map<K, V>
[src]
impl<K: PartialEq, V: PartialEq> PartialEq<Map<K, V>> for Map<K, V>
[src]
impl<K: Eq, V: Eq> Eq for Map<K, V>
[src]
impl<'_, Q: Eq + ?Sized, K: Eq + Borrow<Q>, V> Index<&'_ Q> for Map<K, V>
[src]
impl<'a, K, V> IntoIterator for &'a Map<K, V>
[src]
type Item = (&'a K, &'a V)
The type of the elements being iterated over.
type IntoIter = Map<Iter<'a, (K, V)>, fn(_: &'a (K, V)) -> (&'a K, &'a V)>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a, K, V> IntoIterator for &'a mut Map<K, V>
[src]
type Item = (&'a mut K, &'a mut V)
The type of the elements being iterated over.
type IntoIter = Map<IterMut<'a, (K, V)>, fn(_: &'a mut (K, V)) -> (&'a mut K, &'a mut V)>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<K, V> IntoIterator for Map<K, V>
[src]
type Item = (K, V)
The type of the elements being iterated over.
type IntoIter = IntoIter<(K, V)>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<K: Eq, V> FromIterator<(K, V)> for Map<K, V>
[src]
fn from_iter<T: IntoIterator<Item = (K, V)>>(iter: T) -> Self
[src]
impl<K: Eq, V> Extend<(K, V)> for Map<K, V>
[src]
fn extend<T: IntoIterator<Item = (K, V)>>(&mut self, iter: T)
[src]
impl<'a, K: Copy + Eq, V: Copy> Extend<(&'a K, &'a V)> for Map<K, V>
[src]
fn extend<T: IntoIterator<Item = (&'a K, &'a V)>>(&mut self, iter: T)
[src]
impl<K: Clone, V: Clone> Clone for Map<K, V>
[src]
fn clone(&self) -> Map<K, V>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<K: Default, V: Default> Default for Map<K, V>
[src]
Auto Trait Implementations
impl<K, V> Unpin for Map<K, V> where
K: Unpin,
V: Unpin,
K: Unpin,
V: Unpin,
impl<K, V> Send for Map<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> Sync for Map<K, V> where
K: Sync,
V: Sync,
K: Sync,
V: Sync,
Blanket Implementations
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
fn into_iter(self) -> I
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.