[][src]Struct map_vec::map::Map

pub struct Map<K, V> { /* fields omitted */ }

map_vec::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 = map_vec::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]

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]

pub fn get_key_value<Q: ?Sized>(&self, key: &Q) -> Option<(&K, &V)> where
    K: Borrow<Q>,
    Q: Eq
[src]

pub fn get_mut<Q: ?Sized>(&mut self, key: &Q) -> Option<&mut V> where
    K: Borrow<Q>,
    Q: Eq
[src]

pub fn insert(&mut self, key: K, value: V) -> Option<V>[src]

pub fn is_empty(&self) -> bool[src]

pub fn iter(
    &self
) -> impl Iterator<Item = (&K, &V)> + DoubleEndedIterator + ExactSizeIterator
[src]

pub fn iter_mut(
    &mut self
) -> impl Iterator<Item = (&mut K, &mut V)> + DoubleEndedIterator + ExactSizeIterator
[src]

pub fn keys(
    &self
) -> impl Iterator<Item = &K> + DoubleEndedIterator + ExactSizeIterator
[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]

pub fn remove_entry<Q: ?Sized>(&mut self, key: &Q) -> Option<(K, V)> where
    K: Borrow<Q>,
    Q: Eq
[src]

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<(), TryReserveError>[src]

pub fn values(
    &self
) -> impl Iterator<Item = &V> + DoubleEndedIterator + ExactSizeIterator
[src]

pub fn values_mut(
    &mut self
) -> impl Iterator<Item = &mut V> + DoubleEndedIterator + ExactSizeIterator
[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]

type Output = V

The returned type after indexing.

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?

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?

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?

impl<K: Eq, V> FromIterator<(K, V)> for Map<K, V>[src]

impl<K: Eq, V> Extend<(K, V)> for Map<K, V>[src]

impl<'a, K: 'a + Copy + Eq, V: 'a + Copy> Extend<(&'a K, &'a V)> for Map<K, V>[src]

impl<K: Clone, V: Clone> Clone for 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]

impl<K, V> Serialize for Map<K, V> where
    K: Serialize + Eq,
    V: Serialize
[src]

impl<'de, K, V> Deserialize<'de> for Map<K, V> where
    K: Deserialize<'de> + Eq,
    V: Deserialize<'de>, 
[src]

Auto Trait Implementations

impl<K, V> Unpin for Map<K, V> where
    K: Unpin,
    V: Unpin

impl<K, V> Sync for Map<K, V> where
    K: Sync,
    V: Sync

impl<K, V> Send for Map<K, V> where
    K: Send,
    V: Send

impl<K, V> UnwindSafe for Map<K, V> where
    K: UnwindSafe,
    V: UnwindSafe

impl<K, V> RefUnwindSafe for Map<K, V> where
    K: RefUnwindSafe,
    V: RefUnwindSafe

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<I> IntoIterator for I where
    I: Iterator
[src]

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?

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]