[−][src]Struct map_vec::map::Map
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]
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
) -> impl Iterator<Item = (&K, &V)> + DoubleEndedIterator + ExactSizeIterator
[src]
&self
) -> impl Iterator<Item = (&K, &V)> + DoubleEndedIterator + ExactSizeIterator
pub fn iter_mut(
&mut self
) -> impl Iterator<Item = (&mut K, &mut V)> + DoubleEndedIterator + ExactSizeIterator
[src]
&mut self
) -> impl Iterator<Item = (&mut K, &mut V)> + DoubleEndedIterator + ExactSizeIterator
pub fn keys(
&self
) -> impl Iterator<Item = &K> + DoubleEndedIterator + ExactSizeIterator
[src]
&self
) -> impl Iterator<Item = &K> + DoubleEndedIterator + ExactSizeIterator
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<(), TryReserveError>
[src]
pub fn values(
&self
) -> impl Iterator<Item = &V> + DoubleEndedIterator + ExactSizeIterator
[src]
&self
) -> impl Iterator<Item = &V> + DoubleEndedIterator + ExactSizeIterator
pub fn values_mut(
&mut self
) -> impl Iterator<Item = &mut V> + DoubleEndedIterator + ExactSizeIterator
[src]
&mut self
) -> impl Iterator<Item = &mut V> + DoubleEndedIterator + ExactSizeIterator
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: '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(&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]
impl<K, V> Serialize for Map<K, V> where
K: Serialize + Eq,
V: Serialize,
[src]
K: Serialize + Eq,
V: Serialize,
impl<'de, K, V> Deserialize<'de> for Map<K, V> where
K: Deserialize<'de> + Eq,
V: Deserialize<'de>,
[src]
K: Deserialize<'de> + Eq,
V: Deserialize<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Auto Trait Implementations
impl<K, V> Unpin for Map<K, V> where
K: Unpin,
V: Unpin,
K: Unpin,
V: Unpin,
impl<K, V> Sync for Map<K, V> where
K: Sync,
V: Sync,
K: Sync,
V: Sync,
impl<K, V> Send for Map<K, V> where
K: Send,
V: Send,
K: Send,
V: Send,
impl<K, V> UnwindSafe for Map<K, V> where
K: UnwindSafe,
V: UnwindSafe,
K: UnwindSafe,
V: UnwindSafe,
impl<K, V> RefUnwindSafe for Map<K, V> where
K: RefUnwindSafe,
V: RefUnwindSafe,
K: RefUnwindSafe,
V: RefUnwindSafe,
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.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,