Skip to main content

IndexMap

Struct IndexMap 

Source
pub struct IndexMap<K, V, S = RandomState> { /* private fields */ }
Expand description

A wrapper around [indexmap::IndexMap] that only provides fallible allocation.

Implementations§

Source§

impl<K, V> IndexMap<K, V>

Source

pub fn new() -> Self

Same as [indexmap::IndexMap::new].

Source

pub fn with_capacity(n: usize) -> Result<Self, OutOfMemory>

Same as [indexmap::IndexMap::with_capacity] but returns an error on allocation failure.

Source§

impl<K, V, S> IndexMap<K, V, S>

Source

pub fn with_capacity_and_hasher( n: usize, hash_builder: S, ) -> Result<Self, OutOfMemory>

Same as [indexmap::IndexMap::with_capacity_and_hasher] but returns an error on allocation failure.

Source

pub const fn with_hasher(hash_builder: S) -> Self

Same as [indexmap::IndexMap::with_hasher].

Source

pub fn capacity(&self) -> usize

Same as [indexmap::IndexMap::capacity].

Source

pub fn hasher(&self) -> &S

Same as [indexmap::IndexMap::hasher].

Source

pub fn len(&self) -> usize

Same as [indexmap::IndexMap::len].

Source

pub fn is_empty(&self) -> bool

Same as [indexmap::IndexMap::is_empty].

Source

pub fn iter(&self) -> Iter<'_, K, V>

Same as [indexmap::IndexMap::iter].

Source

pub fn iter_mut(&mut self) -> IterMut<'_, K, V>

Same as [indexmap::IndexMap::iter_mut].

Source

pub fn keys(&self) -> Keys<'_, K, V>

Same as [indexmap::IndexMap::keys].

Source

pub fn into_keys(self) -> IntoKeys<K, V>

Same as [indexmap::IndexMap::into_keys].

Source

pub fn values(&self) -> Values<'_, K, V>

Same as [indexmap::IndexMap::values].

Source

pub fn values_mut(&mut self) -> ValuesMut<'_, K, V>

Same as [indexmap::IndexMap::values_mut].

Source

pub fn into_values(self) -> IntoValues<K, V>

Same as [indexmap::IndexMap::into_values].

Source

pub fn clear(&mut self)

Same as [indexmap::IndexMap::clear].

Source

pub fn truncate(&mut self, len: usize)

Same as [indexmap::IndexMap::truncate].

Source

pub fn drain<R>(&mut self, range: R) -> Drain<'_, K, V>
where R: RangeBounds<usize>,

Same as [indexmap::IndexMap::drain].

Source

pub fn extract_if<F, R>(&mut self, range: R, pred: F) -> ExtractIf<'_, K, V, F>
where F: FnMut(&K, &mut V) -> bool, R: RangeBounds<usize>,

Same as [indexmap::IndexMap::extract_if].

Source

pub fn split_off(&mut self, at: usize) -> Result<Self, OutOfMemory>
where K: Eq + Hash, S: BuildHasher + TryClone,

Same as [indexmap::IndexMap::split_off] but returns an error on allocation failure.

Source

pub fn reserve(&mut self, additional: usize) -> Result<(), OutOfMemory>

Same as [indexmap::IndexMap::reserve] but returns an error on allocation failure.

Source

pub fn reserve_exact(&mut self, additional: usize) -> Result<(), OutOfMemory>

Same as [indexmap::IndexMap::reserve_exact] but returns an error on allocation failure.

Source§

impl<K, V, S> IndexMap<K, V, S>
where K: Hash + Eq, S: BuildHasher,

Source

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

Same as [indexmap::IndexMap::insert] but returns an error on allocation failure.

Source

pub fn insert_full( &mut self, key: K, value: V, ) -> Result<(usize, Option<V>), OutOfMemory>

Same as [indexmap::IndexMap::insert_full] but returns an error on allocation failure.

Source

pub fn insert_sorted( &mut self, key: K, value: V, ) -> Result<(usize, Option<V>), OutOfMemory>
where K: Ord,

Same as [indexmap::IndexMap::insert_sorted] but returns an error on allocation failure.

Source

pub fn insert_sorted_by<F>( &mut self, key: K, value: V, cmp: F, ) -> Result<(usize, Option<V>), OutOfMemory>
where F: FnMut(&K, &V, &K, &V) -> Ordering,

Same as [indexmap::IndexMap::insert_sorted_by] but returns an error on allocation failure.

Source

pub fn insert_sorted_by_key<B, F>( &mut self, key: K, value: V, sort_key: F, ) -> Result<(usize, Option<V>), OutOfMemory>
where B: Ord, F: FnMut(&K, &V) -> B,

Same as [indexmap::IndexMap::insert_sorted_by_key] but returns an error on allocation failure.

Source

pub fn insert_before( &mut self, index: usize, key: K, value: V, ) -> Result<(usize, Option<V>), OutOfMemory>

Same as [indexmap::IndexMap::insert_before] but returns an error on allocation failure.

Source

pub fn shift_insert( &mut self, index: usize, key: K, value: V, ) -> Result<Option<V>, OutOfMemory>

Same as [indexmap::IndexMap::shift_insert] but returns an error on allocation failure.

Source

pub fn replace_index(&mut self, index: usize, key: K) -> Result<K, (usize, K)>

Same as [indexmap::IndexMap::shift_insert].

Source§

impl<K, V, S> IndexMap<K, V, S>
where S: BuildHasher,

Source

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

Same as [indexmap::IndexMap::contains_key].

Source

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

Same as [indexmap::IndexMap::get].

Source

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

Same as [indexmap::IndexMap::get_key_value].

Source

pub fn get_full<Q>(&self, key: &Q) -> Option<(usize, &K, &V)>
where Q: ?Sized + Hash + Eq, K: Borrow<Q>,

Same as [indexmap::IndexMap::get_full].

Source

pub fn get_index_of<Q>(&self, key: &Q) -> Option<usize>
where Q: ?Sized + Hash + Eq, K: Borrow<Q>,

Same as [indexmap::IndexMap::get_index_of].

Source

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

Same as [indexmap::IndexMap::get_mut].

Source

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

Same as [indexmap::IndexMap::get_key_value_mut].

Source

pub fn get_full_mut<Q>(&mut self, key: &Q) -> Option<(usize, &K, &mut V)>
where Q: ?Sized + Hash + Eq, K: Borrow<Q>,

Same as [indexmap::IndexMap::get_full_mut].

Source

pub fn get_disjoint_mut<Q, const N: usize>( &mut self, keys: [&Q; N], ) -> [Option<&mut V>; N]
where Q: ?Sized + Hash + Eq, K: Borrow<Q>,

Same as [indexmap::IndexMap::get_disjoint_mut].

Source

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

Same as [indexmap::IndexMap::swap_remove].

Source

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

Same as [indexmap::IndexMap::swap_remove_entry].

Source

pub fn swap_remove_full<Q>(&mut self, key: &Q) -> Option<(usize, K, V)>
where Q: ?Sized + Hash + Eq, K: Borrow<Q>,

Same as [indexmap::IndexMap::swap_remove_full].

Source

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

Same as [indexmap::IndexMap::shift_remove].

Source

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

Same as [indexmap::IndexMap::shift_remove_entry].

Source

pub fn shift_remove_full<Q>(&mut self, key: &Q) -> Option<(usize, K, V)>
where Q: ?Sized + Hash + Eq, K: Borrow<Q>,

Same as [indexmap::IndexMap::shift_remove_full].

Source§

impl<K, V, S> IndexMap<K, V, S>

Source

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

Same as [indexmap::IndexMap::pop].

Source

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

Same as [indexmap::IndexMap::retain].

Source

pub fn sort_keys(&mut self)
where K: Ord,

Same as [indexmap::IndexMap::sort_keys].

Source

pub fn sort_by<F>(&mut self, cmp: F)
where F: FnMut(&K, &V, &K, &V) -> Ordering,

Same as [indexmap::IndexMap::sort_by].

Source

pub fn sorted_by<F>(self, cmp: F) -> IntoIter<K, V>
where F: FnMut(&K, &V, &K, &V) -> Ordering,

Same as [indexmap::IndexMap::sorted_by].

Source

pub fn sort_by_key<T, F>(&mut self, sort_key: F)
where T: Ord, F: FnMut(&K, &V) -> T,

Same as [indexmap::IndexMap::sort_by_key].

Source

pub fn sort_unstable_keys(&mut self)
where K: Ord,

Same as [indexmap::IndexMap::sort_unstable_keys].

Source

pub fn sort_unstable_by<F>(&mut self, cmp: F)
where F: FnMut(&K, &V, &K, &V) -> Ordering,

Same as [indexmap::IndexMap::sort_unstable_by].

Source

pub fn sorted_unstable_by<F>(self, cmp: F) -> IntoIter<K, V>
where F: FnMut(&K, &V, &K, &V) -> Ordering,

Same as [indexmap::IndexMap::sorted_unstable_by].

Source

pub fn sort_unstable_by_key<T, F>(&mut self, sort_key: F)
where T: Ord, F: FnMut(&K, &V) -> T,

Same as [indexmap::IndexMap::sort_unstable_by_key].

Source

pub fn binary_search_keys(&self, x: &K) -> Result<usize, usize>
where K: Ord,

Same as [indexmap::IndexMap::binary_search_keys].

Source

pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
where F: FnMut(&'a K, &'a V) -> Ordering,

Same as [indexmap::IndexMap::binary_search_by].

Source

pub fn binary_search_by_key<'a, B, F>( &'a self, b: &B, f: F, ) -> Result<usize, usize>
where F: FnMut(&'a K, &'a V) -> B, B: Ord,

Same as [indexmap::IndexMap::binary_search_by_key].

Source

pub fn is_sorted(&self) -> bool
where K: PartialOrd,

Same as [indexmap::IndexMap::is_sorted].

Source

pub fn is_sorted_by<'a, F>(&'a self, cmp: F) -> bool
where F: FnMut(&'a K, &'a V, &'a K, &'a V) -> bool,

Same as [indexmap::IndexMap::is_sorted_by].

Source

pub fn is_sorted_by_key<'a, F, T>(&'a self, sort_key: F) -> bool
where F: FnMut(&'a K, &'a V) -> T, T: PartialOrd,

Same as [indexmap::IndexMap::is_sorted_by_key].

Source

pub fn partition_point<P>(&self, pred: P) -> usize
where P: FnMut(&K, &V) -> bool,

Same as [indexmap::IndexMap::partition_point].

Source

pub fn reverse(&mut self)

Same as [indexmap::IndexMap::reverse].

Source

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

Same as [indexmap::IndexMap::get_index].

Source

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

Same as [indexmap::IndexMap::get_index_mut].

Source

pub fn get_disjoint_indices_mut<const N: usize>( &mut self, indices: [usize; N], ) -> Result<[(&K, &mut V); N], GetDisjointMutError>

Same as [indexmap::IndexMap::get_disjoint_indices_mut].

Source

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

Same as [indexmap::IndexMap::first].

Source

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

Same as [indexmap::IndexMap::first_mut].

Source

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

Same as [indexmap::IndexMap::last].

Source

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

Same as [indexmap::IndexMap::last_mut].

Source

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

Same as [indexmap::IndexMap::swap_remove_index].

Source

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

Same as [indexmap::IndexMap::shift_remove_index].

Source

pub fn move_index(&mut self, from: usize, to: usize)

Same as [indexmap::IndexMap::move_index].

Source

pub fn swap_indices(&mut self, a: usize, b: usize)

Same as [indexmap::IndexMap::swap_indices].

Trait Implementations§

Source§

impl<K, V, S> Debug for IndexMap<K, V, S>
where K: Debug, V: Debug, S: Debug,

Source§

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

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

impl<K, V, S> Default for IndexMap<K, V, S>
where S: Default,

Source§

fn default() -> Self

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

impl<'de, K, V> Deserialize<'de> for IndexMap<K, V>
where K: Deserialize<'de> + Hash + Eq, V: Deserialize<'de>,

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<K, V, S> From<IndexMap<K, V, S>> for IndexMap<K, V, S>

Source§

fn from(map: IndexMap<K, V, S>) -> Self

Converts to this type from the input type.
Source§

impl<K, V, S> From<IndexMap<K, V, S>> for IndexMap<K, V, S>

Source§

fn from(inner: IndexMap<K, V, S>) -> Self

Converts to this type from the input type.
Source§

impl<K, V, Q, S> Index<&Q> for IndexMap<K, V, S>
where Q: ?Sized + Hash + Eq, K: Borrow<Q>, S: BuildHasher,

Source§

type Output = V

The returned type after indexing.
Source§

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

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

impl<K, V, S> Index<usize> for IndexMap<K, V, S>

Source§

type Output = V

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &V

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

impl<K, V, Q, S> IndexMut<&Q> for IndexMap<K, V, S>
where Q: ?Sized + Hash + Eq, K: Borrow<Q>, S: BuildHasher,

Source§

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

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

impl<K, V, S> IndexMut<usize> for IndexMap<K, V, S>

Source§

fn index_mut(&mut self, index: usize) -> &mut V

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

impl<'a, K, V, S> IntoIterator for &'a IndexMap<K, V, S>

Source§

type Item = (&'a K, &'a V)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, K, V>

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<'a, K, V, S> IntoIterator for &'a mut IndexMap<K, V, S>

Source§

type Item = (&'a K, &'a mut V)

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, K, V>

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, V, S> IntoIterator for IndexMap<K, V, S>

Source§

type Item = (K, V)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<K, V>

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, V1, S1, V2, S2> PartialEq<IndexMap<K, V2, S2>> for IndexMap<K, V1, S1>
where K: Hash + Eq, V1: PartialEq<V2>, S1: BuildHasher, S2: BuildHasher,

Source§

fn eq(&self, other: &IndexMap<K, V2, S2>) -> 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, V, H> Serialize for IndexMap<K, V, H>
where K: Serialize, V: Serialize,

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<K, V, S> TryClone for IndexMap<K, V, S>
where K: Eq + Hash + TryClone, V: TryClone, S: BuildHasher + TryClone,

Source§

fn try_clone(&self) -> Result<Self, OutOfMemory>

Attempt to clone self, returning an error if any allocation fails during cloning.
Source§

impl<K, V, S> Eq for IndexMap<K, V, S>
where K: Eq + Hash, V: Eq, S: BuildHasher,

Auto Trait Implementations§

§

impl<K, V, S> Freeze for IndexMap<K, V, S>
where S: Freeze,

§

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

§

impl<K, V, S> Send for IndexMap<K, V, S>
where S: Send, K: Send, V: Send,

§

impl<K, V, S> Sync for IndexMap<K, V, S>
where S: Sync, K: Sync, V: Sync,

§

impl<K, V, S> Unpin for IndexMap<K, V, S>
where S: Unpin, K: Unpin, V: Unpin,

§

impl<K, V, S> UnwindSafe for IndexMap<K, V, S>
where S: UnwindSafe, K: UnwindSafe, V: UnwindSafe,

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
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

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