Struct compactmap::wrapped::CompactMap
[−]
[src]
pub struct CompactMap<K: Into<usize> + From<usize>, V> { /* fields omitted */ }
Special version of CompactMap that uses your usize-equivalent types as keys
You are expected to use newtype-style structs like struct MyToken(usize);
for this
If needed, you can cheat with into_unwrapped
, unwrapped
and so on.
For example, this will fail:
#[macro_use] extern crate compactmap; fn main() { use compactmap::wrapped::CompactMap; declare_compactmap_token!(Mom); declare_compactmap_token!(Lol); let mut m1: CompactMap<Mom, u64> = CompactMap::new(); let mut m2: CompactMap<Lol, u64> = CompactMap::new(); let q = m1.insert(123); m2.remove(q); // expected type `main::Lol`, found type `main::Mom` }
Methods
impl<K: Into<usize> + From<usize>, V> CompactMap<K, V>
[src]
fn into_unwrapped(self) -> CompactMap<V>
[src]
Extract underlying unwrapped map
fn from_unwrapped(s: CompactMap<V>) -> Self
[src]
Wrap the map. You are responsible that it is the correct one
fn unwrapped(&self) -> &CompactMap<V>
[src]
Temporarily use the map without the safety wrapper
fn unwrapped_mut(&mut self) -> &mut CompactMap<V>
[src]
Temporarily use the map without the safety wrapper
impl<K: Into<usize> + From<usize>, V> CompactMap<K, V>
[src]
fn new() -> Self
[src]
fn with_capacity(capacity: usize) -> Self
[src]
fn capacity(&self) -> usize
[src]
fn reserve(&mut self, len: usize)
[src]
fn reserve_exact(&mut self, len: usize)
[src]
fn clear(&mut self)
[src]
fn is_empty_slow(&self) -> bool
[src]
fn insert(&mut self, v: V) -> K
[src]
fn remove(&mut self, i: K) -> Option<V>
[src]
fn get(&self, i: K) -> Option<&V>
[src]
fn get_mut(&mut self, i: K) -> Option<&mut V>
[src]
fn iter(&self) -> Iter<K, V>
[src]
Returns an iterator visiting all key-value pairs in unspecified order.
The iterator's element type is (K, &'r V)
.
fn iter_mut(&mut self) -> IterMut<K, V>
[src]
Returns an iterator visiting all key-value pairs in unspecified order,
with mutable references to the values.
The iterator's element type is (K, &'r mut V)
fn into_iter(self) -> IntoIter<K, V>
[src]
Returns an iterator visiting all key-value pairs in unspecified order,
the keys, consuming the original CompactMap
.
The iterator's element type is (K, V)
.
fn keys(&self) -> Keys<K, V>
[src]
Returns an iterator visiting all keys in some order.
The iterator's element type is K
.
fn values(&self) -> Values<V>
[src]
fn values_mut(&mut self) -> ValuesMut<V>
[src]
fn len_slow(&self) -> usize
[src]
fn shrink_to_fit(&mut self)
[src]
fn drain(&mut self) -> Drain<K, V>
[src]
Returns an iterator visiting all key-value pairs in ascending order of
the keys, emptying (but not consuming) the original CompactMap
.
The iterator's element type is (K, V)
. Keeps the allocated memory for reuse.
Trait Implementations
impl<K: Default + Into<usize> + From<usize>, V: Default> Default for CompactMap<K, V>
[src]
fn default() -> CompactMap<K, V>
[src]
Returns the "default value" for a type. Read more
impl<K: Hash + Into<usize> + From<usize>, V: Hash> Hash for CompactMap<K, V>
[src]
fn hash<__HKV: Hasher>(&self, __arg_0: &mut __HKV)
[src]
Feeds this value into the given [Hasher
]. Read more
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl<K: PartialEq + Into<usize> + From<usize>, V: PartialEq> PartialEq for CompactMap<K, V>
[src]
fn eq(&self, __arg_0: &CompactMap<K, V>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &CompactMap<K, V>) -> bool
[src]
This method tests for !=
.
impl<K: Eq + Into<usize> + From<usize>, V: Eq> Eq for CompactMap<K, V>
[src]
impl<K: PartialOrd + Into<usize> + From<usize>, V: PartialOrd> PartialOrd for CompactMap<K, V>
[src]
fn partial_cmp(&self, __arg_0: &CompactMap<K, V>) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, __arg_0: &CompactMap<K, V>) -> bool
[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, __arg_0: &CompactMap<K, V>) -> bool
[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, __arg_0: &CompactMap<K, V>) -> bool
[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, __arg_0: &CompactMap<K, V>) -> bool
[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl<K: Ord + Into<usize> + From<usize>, V: Ord> Ord for CompactMap<K, V>
[src]
fn cmp(&self, __arg_0: &CompactMap<K, V>) -> Ordering
[src]
This method returns an Ordering
between self
and other
. Read more
fn max(self, other: Self) -> Self
1.22.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.22.0[src]
Compares and returns the minimum of two values. Read more
impl<K: Into<usize> + From<usize>, V> FromIterator<V> for CompactMap<K, V>
[src]
fn from_iter<I>(iter: I) -> CompactMap<K, V> where
I: IntoIterator<Item = V>,
[src]
I: IntoIterator<Item = V>,
Creates a value from an iterator. Read more
impl<'a, K: Into<usize> + From<usize>, V> FromIterator<&'a V> for CompactMap<K, V> where
V: Copy,
[src]
V: Copy,
fn from_iter<I>(iter: I) -> CompactMap<K, V> where
I: IntoIterator<Item = &'a V>,
[src]
I: IntoIterator<Item = &'a V>,
Creates a value from an iterator. Read more
impl<K: Into<usize> + From<usize>, V> Extend<V> for CompactMap<K, V>
[src]
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = V>,
[src]
I: IntoIterator<Item = V>,
Extends a collection with the contents of an iterator. Read more
impl<'a, K: Into<usize> + From<usize>, V> Extend<&'a V> for CompactMap<K, V> where
V: Copy,
[src]
V: Copy,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = &'a V>,
[src]
I: IntoIterator<Item = &'a V>,
Extends a collection with the contents of an iterator. Read more
impl<V, K: Into<usize> + From<usize>> Index<K> for CompactMap<K, V>
[src]
type Output = V
The returned type after indexing.
fn index(&self, i: K) -> &V
[src]
Performs the indexing (container[index]
) operation.
impl<'a, K: Copy + Into<usize> + From<usize>, V> Index<&'a K> for CompactMap<K, V>
[src]
type Output = V
The returned type after indexing.
fn index(&self, i: &K) -> &V
[src]
Performs the indexing (container[index]
) operation.
impl<K: Into<usize> + From<usize>, V> IndexMut<K> for CompactMap<K, V>
[src]
fn index_mut(&mut self, i: K) -> &mut V
[src]
Performs the mutable indexing (container[index]
) operation.
impl<'a, K: Copy + Into<usize> + From<usize>, V> IndexMut<&'a K> for CompactMap<K, V>
[src]
fn index_mut(&mut self, i: &K) -> &mut V
[src]
Performs the mutable indexing (container[index]
) operation.
impl<K: Into<usize> + From<usize>, V: Debug> Debug for CompactMap<K, V>
[src]
impl<'a, K: Into<usize> + From<usize>, V> IntoIterator for &'a CompactMap<K, V>
[src]
type Item = (K, &'a V)
The type of the elements being iterated over.
type IntoIter = Iter<'a, K, V>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Iter<'a, K, V>
[src]
Creates an iterator from a value. Read more
impl<'a, K: Into<usize> + From<usize>, V: 'a> IntoIterator for &'a mut CompactMap<K, V>
[src]
type Item = (K, &'a mut V)
The type of the elements being iterated over.
type IntoIter = IterMut<'a, K, V>
Which kind of iterator are we turning this into?
fn into_iter(self) -> IterMut<'a, K, V>
[src]
Creates an iterator from a value. Read more