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:

This code doesn't compile so be extra careful!
#[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]

[src]

Extract underlying unwrapped map

[src]

Wrap the map. You are responsible that it is the correct one

[src]

Temporarily use the map without the safety wrapper

[src]

Temporarily use the map without the safety wrapper

impl<K: Into<usize> + From<usize>, V> CompactMap<K, V>
[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

[src]

Returns an iterator visiting all key-value pairs in unspecified order. The iterator's element type is (K, &'r 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)

[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).

[src]

Returns an iterator visiting all keys in some order. The iterator's element type is K.

[src]

[src]

[src]

[src]

[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]

[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]

[src]

Feeds this value into the given [Hasher]. Read more

1.3.0
[src]

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]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[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]

[src]

This method returns an ordering between self and other values if one exists. Read more

[src]

This method tests less than (for self and other) and is used by the < operator. Read more

[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

[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]

[src]

This method returns an Ordering between self and other. Read more

1.22.0
[src]

Compares and returns the maximum of two values. Read more

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]

[src]

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]

[src]

Creates a value from an iterator. Read more

impl<K: Into<usize> + From<usize>, V> Extend<V> for CompactMap<K, V>
[src]

[src]

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]

[src]

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]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<'a, K: Copy + Into<usize> + From<usize>, V> Index<&'a K> for CompactMap<K, V>
[src]

The returned type after indexing.

[src]

Performs the indexing (container[index]) operation.

impl<K: Into<usize> + From<usize>, V> IndexMut<K> for CompactMap<K, V>
[src]

[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]

[src]

Performs the mutable indexing (container[index]) operation.

impl<K: Into<usize> + From<usize>, V: Debug> Debug for CompactMap<K, V>
[src]

[src]

Formats the value using the given formatter.

impl<'a, K: Into<usize> + From<usize>, V> IntoIterator for &'a CompactMap<K, V>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[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]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more

impl<K: Into<usize> + From<usize>, V> IntoIterator for CompactMap<K, V>
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

[src]

Creates an iterator from a value. Read more