litemap

Struct LiteMap

Source
pub struct LiteMap<K: ?Sized, V: ?Sized, S = Vec<(K, V)>> { /* private fields */ }
Expand description

A simple “flat” map based on a sorted vector

See the module level documentation for why one should use this.

The API is roughly similar to that of std::collections::BTreeMap.

Implementations§

Source§

impl<K, V> LiteMap<K, V>

Source

pub const fn new_vec() -> Self

Construct a new LiteMap backed by Vec

Source§

impl<K, V, S> LiteMap<K, V, S>

Source

pub const fn from_sorted_store_unchecked(values: S) -> Self

Construct a new LiteMap using the given values

The store must be sorted and have no duplicate keys.

Source§

impl<K, V> LiteMap<K, V, Vec<(K, V)>>

Source

pub fn into_tuple_vec(self) -> Vec<(K, V)>

Convert a LiteMap into a sorted Vec<(K, V)>.

Source§

impl<K: ?Sized, V: ?Sized, S> LiteMap<K, V, S>
where S: StoreConstEmpty<K, V>,

Source

pub const fn new() -> Self

Create a new empty LiteMap

Source§

impl<K: ?Sized, V: ?Sized, S> LiteMap<K, V, S>
where S: Store<K, V>,

Source

pub fn len(&self) -> usize

The number of elements in the LiteMap

Source

pub fn is_empty(&self) -> bool

Whether the LiteMap is empty

Source

pub fn get_indexed(&self, index: usize) -> Option<(&K, &V)>

Get the key-value pair residing at a particular index

In most cases, prefer LiteMap::get() over this method.

Source

pub fn first(&self) -> Option<(&K, &V)>

Get the lowest-rank key/value pair from the LiteMap, if it exists.

§Examples
use litemap::LiteMap;

let mut map =
    LiteMap::<i32, &str, Vec<_>>::from_iter([(1, "uno"), (3, "tres")]);

assert_eq!(map.first(), Some((&1, &"uno")));
Source

pub fn last(&self) -> Option<(&K, &V)>

Get the highest-rank key/value pair from the LiteMap, if it exists.

§Examples
use litemap::LiteMap;

let mut map =
    LiteMap::<i32, &str, Vec<_>>::from_iter([(1, "uno"), (3, "tres")]);

assert_eq!(map.last(), Some((&3, &"tres")));
Source

pub fn to_boxed_keys_values<KB: ?Sized, VB: ?Sized, SB>( &self, ) -> LiteMap<Box<KB>, Box<VB>, SB>
where SB: StoreMut<Box<KB>, Box<VB>>, K: Borrow<KB>, V: Borrow<VB>, Box<KB>: for<'a> From<&'a KB>, Box<VB>: for<'a> From<&'a VB>,

Returns a new LiteMap with owned keys and values.

The trait bounds allow transforming most slice and string types.

§Examples
use litemap::LiteMap;

let mut map: LiteMap<&str, &str> = LiteMap::new_vec();
map.insert("one", "uno");
map.insert("two", "dos");

let boxed_map: LiteMap<Box<str>, Box<str>> = map.to_boxed_keys_values();

assert_eq!(boxed_map.get("one"), Some(&Box::from("uno")));
Source

pub fn to_boxed_keys<KB: ?Sized, SB>(&self) -> LiteMap<Box<KB>, V, SB>
where V: Clone, SB: StoreMut<Box<KB>, V>, K: Borrow<KB>, Box<KB>: for<'a> From<&'a KB>,

Returns a new LiteMap with owned keys and cloned values.

The trait bounds allow transforming most slice and string types.

§Examples
use litemap::LiteMap;

let mut map: LiteMap<&str, usize> = LiteMap::new_vec();
map.insert("one", 11);
map.insert("two", 22);

let boxed_map: LiteMap<Box<str>, usize> = map.to_boxed_keys();

assert_eq!(boxed_map.get("one"), Some(&11));
Source

pub fn to_boxed_values<VB: ?Sized, SB>(&self) -> LiteMap<K, Box<VB>, SB>
where K: Clone, SB: StoreMut<K, Box<VB>>, V: Borrow<VB>, Box<VB>: for<'a> From<&'a VB>,

Returns a new LiteMap with cloned keys and owned values.

The trait bounds allow transforming most slice and string types.

§Examples
use litemap::LiteMap;

let mut map: LiteMap<usize, &str> = LiteMap::new_vec();
map.insert(11, "uno");
map.insert(22, "dos");

let boxed_map: LiteMap<usize, Box<str>> = map.to_boxed_values();

assert_eq!(boxed_map.get(&11), Some(&Box::from("uno")));
Source§

impl<K, V: ?Sized, S> LiteMap<K, V, S>
where K: Ord + ?Sized, S: Store<K, V>,

Source

pub fn get<Q>(&self, key: &Q) -> Option<&V>
where K: Borrow<Q>, Q: Ord + ?Sized,

Get the value associated with key, if it exists.

use litemap::LiteMap;

let mut map = LiteMap::new_vec();
map.insert(1, "one");
map.insert(2, "two");
assert_eq!(map.get(&1), Some(&"one"));
assert_eq!(map.get(&3), None);
Source

pub fn get_by(&self, predicate: impl FnMut(&K) -> Ordering) -> Option<&V>

Binary search the map with predicate to find a key, returning the value.

Source

pub fn contains_key<Q>(&self, key: &Q) -> bool
where K: Borrow<Q>, Q: Ord + ?Sized,

Returns whether key is contained in this map

use litemap::LiteMap;

let mut map = LiteMap::new_vec();
map.insert(1, "one");
map.insert(2, "two");
assert!(map.contains_key(&1));
assert!(!map.contains_key(&3));
Source

pub fn find_index<Q>(&self, key: &Q) -> Result<usize, usize>
where K: Borrow<Q>, Q: Ord + ?Sized,

Obtain the index for a given key, or if the key is not found, the index at which it would be inserted.

(The return value works equivalently to slice::binary_search_by())

The indices returned can be used with Self::get_indexed(). Prefer using Self::get() directly where possible.

Source§

impl<K: ?Sized, V: ?Sized, S> LiteMap<K, V, S>
where S: StoreSlice<K, V>,

Source

pub fn get_indexed_range( &self, range: Range<usize>, ) -> Option<LiteMap<K, V, &S::Slice>>

Creates a new LiteMap from a range of the current LiteMap.

§Examples
use litemap::LiteMap;

let mut map = LiteMap::new_vec();
map.insert(1, "one");
map.insert(2, "two");
map.insert(3, "three");

let mut sub_map = map.get_indexed_range(1..3).expect("valid range");
assert_eq!(sub_map.get(&1), None);
assert_eq!(sub_map.get(&2), Some(&"two"));
assert_eq!(sub_map.get(&3), Some(&"three"));
Source

pub fn as_sliced(&self) -> LiteMap<K, V, &S::Slice>

Borrows this LiteMap as one of its slice type.

This can be useful in situations where you need a LiteMap by value but do not want to clone the owned version.

§Examples
use litemap::LiteMap;

let mut map = LiteMap::new_vec();
map.insert(1, "one");
map.insert(2, "two");

let borrowed_map = map.as_sliced();
assert_eq!(borrowed_map.get(&1), Some(&"one"));
assert_eq!(borrowed_map.get(&2), Some(&"two"));
Source

pub fn as_slice(&self) -> &S::Slice

Borrows the backing buffer of this LiteMap as its slice type.

The slice will be sorted.

§Examples
use litemap::LiteMap;

let mut map = LiteMap::new_vec();
map.insert(1, "one");
map.insert(2, "two");

let slice = map.as_slice();
assert_eq!(slice, &[(1, "one"), (2, "two")]);
Source§

impl<'a, K: 'a, V: 'a, S> LiteMap<K, V, S>
where S: Store<K, V>,

Source

pub fn to_borrowed_keys_values<KB: ?Sized, VB: ?Sized, SB>( &'a self, ) -> LiteMap<&'a KB, &'a VB, SB>
where K: Borrow<KB>, V: Borrow<VB>, SB: StoreMut<&'a KB, &'a VB>,

Returns a new LiteMap with keys and values borrowed from this one.

§Examples
use litemap::LiteMap;

let mut map: LiteMap<Box<usize>, String> = LiteMap::new_vec();
map.insert(Box::new(1), "one".to_string());
map.insert(Box::new(2), "two".to_string());

let borrowed_map: LiteMap<&usize, &str> = map.to_borrowed_keys_values();

assert_eq!(borrowed_map.get(&1), Some(&"one"));
Source

pub fn to_borrowed_keys<KB: ?Sized, SB>(&'a self) -> LiteMap<&'a KB, V, SB>
where K: Borrow<KB>, V: Clone, SB: StoreMut<&'a KB, V>,

Returns a new LiteMap with keys borrowed from this one and cloned values.

§Examples
use litemap::LiteMap;

let mut map: LiteMap<Box<usize>, String> = LiteMap::new_vec();
map.insert(Box::new(1), "one".to_string());
map.insert(Box::new(2), "two".to_string());

let borrowed_map: LiteMap<&usize, String> = map.to_borrowed_keys();

assert_eq!(borrowed_map.get(&1), Some(&"one".to_string()));
Source

pub fn to_borrowed_values<VB: ?Sized, SB>(&'a self) -> LiteMap<K, &'a VB, SB>
where K: Clone, V: Borrow<VB>, SB: StoreMut<K, &'a VB>,

Returns a new LiteMap with values borrowed from this one and cloned keys.

§Examples
use litemap::LiteMap;

let mut map: LiteMap<Box<usize>, String> = LiteMap::new_vec();
map.insert(Box::new(1), "one".to_string());
map.insert(Box::new(2), "two".to_string());

let borrowed_map: LiteMap<Box<usize>, &str> = map.to_borrowed_values();

assert_eq!(borrowed_map.get(&1), Some(&"one"));
Source§

impl<K, V, S> LiteMap<K, V, S>
where S: StoreMut<K, V>,

Source

pub fn with_capacity(capacity: usize) -> Self

Construct a new LiteMap with a given capacity

Source

pub fn clear(&mut self)

Remove all elements from the LiteMap

Source

pub fn reserve(&mut self, additional: usize)

Reserve capacity for additional more elements to be inserted into the LiteMap to avoid frequent reallocations.

See Vec::reserve() for more information.

Source§

impl<K, V, S> LiteMap<K, V, S>
where K: Ord, S: StoreMut<K, V>,

Source

pub fn get_mut<Q>(&mut self, key: &Q) -> Option<&mut V>
where K: Borrow<Q>, Q: Ord + ?Sized,

Get the value associated with key, if it exists, as a mutable reference.

use litemap::LiteMap;

let mut map = LiteMap::new_vec();
map.insert(1, "one");
map.insert(2, "two");
if let Some(mut v) = map.get_mut(&1) {
    *v = "uno";
}
assert_eq!(map.get(&1), Some(&"uno"));
Source

pub fn try_append(&mut self, key: K, value: V) -> Option<(K, V)>

Appends value with key to the end of the underlying vector, returning key and value if it failed. Useful for extending with an existing sorted list.

use litemap::LiteMap;

let mut map = LiteMap::new_vec();
assert!(map.try_append(1, "uno").is_none());
assert!(map.try_append(3, "tres").is_none());

assert!(
    matches!(map.try_append(3, "tres-updated"), Some((3, "tres-updated"))),
    "append duplicate of last key",
);

assert!(
    matches!(map.try_append(2, "dos"), Some((2, "dos"))),
    "append out of order"
);

assert_eq!(map.get(&1), Some(&"uno"));

// contains the original value for the key: 3
assert_eq!(map.get(&3), Some(&"tres"));

// not appended since it wasn't in order
assert_eq!(map.get(&2), None);
Source

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

Insert value with key, returning the existing value if it exists.

use litemap::LiteMap;

let mut map = LiteMap::new_vec();
map.insert(1, "one");
map.insert(2, "two");
assert_eq!(map.get(&1), Some(&"one"));
assert_eq!(map.get(&3), None);
Source

pub fn try_insert(&mut self, key: K, value: V) -> Option<(K, V)>

Attempts to insert a unique entry into the map.

If key is not already in the map, inserts it with the corresponding value and returns None.

If key is already in the map, no change is made to the map, and the key and value are returned back to the caller.

use litemap::LiteMap;

let mut map = LiteMap::new_vec();
map.insert(1, "one");
map.insert(3, "three");

// 2 is not yet in the map...
assert_eq!(map.try_insert(2, "two"), None);
assert_eq!(map.len(), 3);

// ...but now it is.
assert_eq!(map.try_insert(2, "TWO"), Some((2, "TWO")));
assert_eq!(map.len(), 3);
Source

pub fn try_get_or_insert<E>( &mut self, key: K, value: impl FnOnce(&K) -> Result<V, E>, ) -> Result<(usize, &V), E>

Attempts to insert a unique entry into the map.

If key is not already in the map, invokes the closure to compute value, inserts the pair into the map, and returns a reference to the value. The closure is passed a reference to the key argument.

If key is already in the map, a reference to the existing value is returned.

Additionally, the index of the value in the map is returned. If it is not desirable to hold on to the mutable reference’s lifetime, the index can be used to access the element via LiteMap::get_indexed().

The closure returns a Result to allow for a fallible insertion function. If the creation of value is infallible, you can use core::convert::Infallible.

use litemap::LiteMap;

/// Helper function to unwrap an `Infallible` result from the insertion function
fn unwrap_infallible<T>(result: Result<T, core::convert::Infallible>) -> T {
    result.unwrap_or_else(|never| match never {})
}

let mut map = LiteMap::new_vec();
map.insert(1, "one");
map.insert(3, "three");

// 2 is not yet in the map...
let result1 = unwrap_infallible(
    map.try_get_or_insert(2, |_| Ok("two"))
);
assert_eq!(result1.1, &"two");
assert_eq!(map.len(), 3);

// ...but now it is.
let result1 = unwrap_infallible(
    map.try_get_or_insert(2, |_| Ok("TWO"))
);
assert_eq!(result1.1, &"two");
assert_eq!(map.len(), 3);
Source

pub fn remove<Q>(&mut self, key: &Q) -> Option<V>
where K: Borrow<Q>, Q: Ord + ?Sized,

Remove the value at key, returning it if it exists.

use litemap::LiteMap;

let mut map = LiteMap::new_vec();
map.insert(1, "one");
map.insert(2, "two");
assert_eq!(map.remove(&1), Some("one"));
assert_eq!(map.get(&1), None);
Source§

impl<'a, K, V: 'a, S> LiteMap<K, V, S>
where K: Ord + 'a, S: StoreIntoIterator<K, V> + StoreFromIterator<K, V>,

Source

pub fn extend_from_litemap(&mut self, other: Self) -> Option<Self>

Insert all elements from other into this LiteMap.

If other contains keys that already exist in self, the values in other replace the corresponding ones in self, and the rejected items from self are returned as a new LiteMap. Otherwise, None is returned.

The implementation of this function is optimized if self and other have no overlap.

§Examples
use litemap::LiteMap;

let mut map1 = LiteMap::new_vec();
map1.insert(1, "one");
map1.insert(2, "two");

let mut map2 = LiteMap::new_vec();
map2.insert(2, "TWO");
map2.insert(4, "FOUR");

let leftovers = map1.extend_from_litemap(map2);

assert_eq!(map1.len(), 3);
assert_eq!(map1.get(&1), Some("one").as_ref());
assert_eq!(map1.get(&2), Some("TWO").as_ref());
assert_eq!(map1.get(&4), Some("FOUR").as_ref());

let map3 = leftovers.expect("Duplicate keys");
assert_eq!(map3.len(), 1);
assert_eq!(map3.get(&2), Some("two").as_ref());
Source§

impl<'a, K: 'a, V: 'a, S> LiteMap<K, V, S>
where S: StoreIterable<'a, K, V>,

Source

pub fn iter(&'a self) -> impl DoubleEndedIterator<Item = (&'a K, &'a V)>

Produce an ordered iterator over key-value pairs

Source

pub fn iter_keys(&'a self) -> impl DoubleEndedIterator<Item = &'a K>

Produce an ordered iterator over keys

Source

pub fn iter_values(&'a self) -> impl DoubleEndedIterator<Item = &'a V>

Produce an iterator over values, ordered by their keys

Source§

impl<'a, K: 'a, V: 'a, S> LiteMap<K, V, S>
where S: StoreIterableMut<'a, K, V>,

Source

pub fn iter_mut( &'a mut self, ) -> impl DoubleEndedIterator<Item = (&'a K, &'a mut V)>

Produce an ordered mutable iterator over key-value pairs

Source§

impl<K, V, S> LiteMap<K, V, S>
where S: StoreMut<K, V>,

Source

pub fn retain<F>(&mut self, predicate: F)
where F: FnMut(&K, &V) -> bool,

Retains only the elements specified by the predicate.

In other words, remove all elements such that f((&k, &v)) returns false.

§Example
use litemap::LiteMap;

let mut map = LiteMap::new_vec();
map.insert(1, "one");
map.insert(2, "two");
map.insert(3, "three");

// Retain elements with odd keys
map.retain(|k, _| k % 2 == 1);

assert_eq!(map.get(&1), Some(&"one"));
assert_eq!(map.get(&2), None);
Source§

impl<'a, K, V> LiteMap<K, V, &'a [(K, V)]>

Source

pub const fn const_len(&self) -> usize

Const version of LiteMap::len() for a slice store.

Note: This function will no longer be needed if const trait behavior is stabilized.

§Examples
use litemap::LiteMap;

static map: LiteMap<&str, usize, &[(&str, usize)]> =
    LiteMap::from_sorted_store_unchecked(&[("a", 11), ("b", 22)]);
static len: usize = map.const_len();
assert_eq!(len, 2);
Source

pub const fn const_is_empty(&self) -> bool

Const version of LiteMap::is_empty() for a slice store.

Note: This function will no longer be needed if const trait behavior is stabilized.

§Examples
use litemap::LiteMap;

static map: LiteMap<&str, usize, &[(&str, usize)]> =
    LiteMap::from_sorted_store_unchecked(&[]);
static is_empty: bool = map.const_is_empty();
assert!(is_empty);
Source

pub const fn const_get_indexed_or_panic(&self, index: usize) -> &'a (K, V)

Const version of LiteMap::get_indexed() for a slice store.

Note: This function will no longer be needed if const trait behavior is stabilized.

§Panics

Panics if the index is out of bounds.

§Examples
use litemap::LiteMap;

static map: LiteMap<&str, usize, &[(&str, usize)]> =
    LiteMap::from_sorted_store_unchecked(&[("a", 11), ("b", 22)]);
static t: &(&str, usize) = map.const_get_indexed_or_panic(0);
assert_eq!(t.0, "a");
assert_eq!(t.1, 11);
Source§

impl<'a, V> LiteMap<&'a str, V, &'a [(&'a str, V)]>

Source

pub const fn const_get_with_index(&self, key: &str) -> Option<(usize, &'a V)>

Const function to get the value associated with a &str key, if it exists.

Also returns the index of the value.

Note: This function will no longer be needed if const trait behavior is stabilized.

§Examples
use litemap::LiteMap;

static map: LiteMap<&str, usize, &[(&str, usize)]> =
    LiteMap::from_sorted_store_unchecked(&[
        ("abc", 11),
        ("bcd", 22),
        ("cde", 33),
        ("def", 44),
        ("efg", 55),
    ]);

static d: Option<(usize, &usize)> = map.const_get_with_index("def");
assert_eq!(d, Some((3, &44)));

static n: Option<(usize, &usize)> = map.const_get_with_index("dng");
assert_eq!(n, None);
Source§

impl<'a, V> LiteMap<&'a [u8], V, &'a [(&'a [u8], V)]>

Source

pub const fn const_get_with_index(&self, key: &[u8]) -> Option<(usize, &'a V)>

Const function to get the value associated with a &[u8] key, if it exists.

Also returns the index of the value.

Note: This function will no longer be needed if const trait behavior is stabilized.

§Examples
use litemap::LiteMap;

static map: LiteMap<&[u8], usize, &[(&[u8], usize)]> =
    LiteMap::from_sorted_store_unchecked(&[
        (b"abc", 11),
        (b"bcd", 22),
        (b"cde", 33),
        (b"def", 44),
        (b"efg", 55),
    ]);

static d: Option<(usize, &usize)> = map.const_get_with_index(b"def");
assert_eq!(d, Some((3, &44)));

static n: Option<(usize, &usize)> = map.const_get_with_index(b"dng");
assert_eq!(n, None);
Source§

impl<'a, V> LiteMap<u8, V, &'a [(u8, V)]>

Source

pub const fn const_get_with_index(&self, key: u8) -> Option<(usize, &'a V)>

Const function to get the value associated with an integer key, if it exists.

Note: This function will no longer be needed if const trait behavior is stabilized.

Also returns the index of the value.

Source§

impl<'a, V> LiteMap<u16, V, &'a [(u16, V)]>

Source

pub const fn const_get_with_index(&self, key: u16) -> Option<(usize, &'a V)>

Const function to get the value associated with an integer key, if it exists.

Note: This function will no longer be needed if const trait behavior is stabilized.

Also returns the index of the value.

Source§

impl<'a, V> LiteMap<u32, V, &'a [(u32, V)]>

Source

pub const fn const_get_with_index(&self, key: u32) -> Option<(usize, &'a V)>

Const function to get the value associated with an integer key, if it exists.

Note: This function will no longer be needed if const trait behavior is stabilized.

Also returns the index of the value.

Source§

impl<'a, V> LiteMap<u64, V, &'a [(u64, V)]>

Source

pub const fn const_get_with_index(&self, key: u64) -> Option<(usize, &'a V)>

Const function to get the value associated with an integer key, if it exists.

Note: This function will no longer be needed if const trait behavior is stabilized.

Also returns the index of the value.

Source§

impl<'a, V> LiteMap<u128, V, &'a [(u128, V)]>

Source

pub const fn const_get_with_index(&self, key: u128) -> Option<(usize, &'a V)>

Const function to get the value associated with an integer key, if it exists.

Note: This function will no longer be needed if const trait behavior is stabilized.

Also returns the index of the value.

Source§

impl<'a, V> LiteMap<usize, V, &'a [(usize, V)]>

Source

pub const fn const_get_with_index(&self, key: usize) -> Option<(usize, &'a V)>

Const function to get the value associated with an integer key, if it exists.

Note: This function will no longer be needed if const trait behavior is stabilized.

Also returns the index of the value.

Source§

impl<'a, V> LiteMap<i8, V, &'a [(i8, V)]>

Source

pub const fn const_get_with_index(&self, key: i8) -> Option<(usize, &'a V)>

Const function to get the value associated with an integer key, if it exists.

Note: This function will no longer be needed if const trait behavior is stabilized.

Also returns the index of the value.

Source§

impl<'a, V> LiteMap<i16, V, &'a [(i16, V)]>

Source

pub const fn const_get_with_index(&self, key: i16) -> Option<(usize, &'a V)>

Const function to get the value associated with an integer key, if it exists.

Note: This function will no longer be needed if const trait behavior is stabilized.

Also returns the index of the value.

Source§

impl<'a, V> LiteMap<i32, V, &'a [(i32, V)]>

Source

pub const fn const_get_with_index(&self, key: i32) -> Option<(usize, &'a V)>

Const function to get the value associated with an integer key, if it exists.

Note: This function will no longer be needed if const trait behavior is stabilized.

Also returns the index of the value.

Source§

impl<'a, V> LiteMap<i64, V, &'a [(i64, V)]>

Source

pub const fn const_get_with_index(&self, key: i64) -> Option<(usize, &'a V)>

Const function to get the value associated with an integer key, if it exists.

Note: This function will no longer be needed if const trait behavior is stabilized.

Also returns the index of the value.

Source§

impl<'a, V> LiteMap<i128, V, &'a [(i128, V)]>

Source

pub const fn const_get_with_index(&self, key: i128) -> Option<(usize, &'a V)>

Const function to get the value associated with an integer key, if it exists.

Note: This function will no longer be needed if const trait behavior is stabilized.

Also returns the index of the value.

Source§

impl<'a, V> LiteMap<isize, V, &'a [(isize, V)]>

Source

pub const fn const_get_with_index(&self, key: isize) -> Option<(usize, &'a V)>

Const function to get the value associated with an integer key, if it exists.

Note: This function will no longer be needed if const trait behavior is stabilized.

Also returns the index of the value.

Trait Implementations§

Source§

impl<K: Clone + ?Sized, V: Clone + ?Sized, S: Clone> Clone for LiteMap<K, V, S>

Source§

fn clone(&self) -> LiteMap<K, V, S>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: Debug + ?Sized, V: Debug + ?Sized, S: Debug> Debug for LiteMap<K, V, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<K, V, S> Default for LiteMap<K, V, S>
where S: Store<K, V> + Default,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<K, V, S> FromIterator<(K, V)> for LiteMap<K, V, S>
where K: Ord, S: StoreFromIterable<K, V>,

Source§

fn from_iter<I: IntoIterator<Item = (K, V)>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<K: Hash + ?Sized, V: Hash + ?Sized, S: Hash> Hash for LiteMap<K, V, S>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<K, V, S> Index<&K> for LiteMap<K, V, S>
where K: Ord, S: Store<K, V>,

Source§

type Output = V

The returned type after indexing.
Source§

fn index(&self, key: &K) -> &V

Performs the indexing (container[index]) operation. Read more
Source§

impl<K, V, S> IndexMut<&K> for LiteMap<K, V, S>
where K: Ord, S: StoreMut<K, V>,

Source§

fn index_mut(&mut self, key: &K) -> &mut V

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<K, V, S> IntoIterator for LiteMap<K, V, S>
where S: StoreIntoIterator<K, V>,

Source§

type Item = (K, V)

The type of the elements being iterated over.
Source§

type IntoIter = <S as StoreIntoIterator<K, V>>::KeyValueIntoIter

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<K: Ord + ?Sized, V: Ord + ?Sized, S: Ord> Ord for LiteMap<K, V, S>

Source§

fn cmp(&self, other: &LiteMap<K, V, S>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<K: PartialEq + ?Sized, V: PartialEq + ?Sized, S: PartialEq> PartialEq for LiteMap<K, V, S>

Source§

fn eq(&self, other: &LiteMap<K, V, S>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<K: PartialOrd + ?Sized, V: PartialOrd + ?Sized, S: PartialOrd> PartialOrd for LiteMap<K, V, S>

Source§

fn partial_cmp(&self, other: &LiteMap<K, V, S>) -> Option<Ordering>

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

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<K: Eq + ?Sized, V: Eq + ?Sized, S: Eq> Eq for LiteMap<K, V, S>

Source§

impl<K: ?Sized, V: ?Sized, S> StructuralPartialEq for LiteMap<K, V, S>

Auto Trait Implementations§

§

impl<K, V, S> Freeze for LiteMap<K, V, S>
where S: Freeze, K: ?Sized, V: ?Sized,

§

impl<K, V, S> RefUnwindSafe for LiteMap<K, V, S>

§

impl<K, V, S> Send for LiteMap<K, V, S>
where S: Send, K: Send + ?Sized, V: Send + ?Sized,

§

impl<K, V, S> Sync for LiteMap<K, V, S>
where S: Sync, K: Sync + ?Sized, V: Sync + ?Sized,

§

impl<K, V, S> Unpin for LiteMap<K, V, S>
where S: Unpin, K: Unpin + ?Sized, V: Unpin + ?Sized,

§

impl<K, V, S> UnwindSafe for LiteMap<K, V, S>
where S: UnwindSafe, K: UnwindSafe + ?Sized, V: UnwindSafe + ?Sized,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.