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>
impl<K, V> IndexMap<K, V>
Sourcepub fn with_capacity(n: usize) -> Result<Self, OutOfMemory>
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>
impl<K, V, S> IndexMap<K, V, S>
Sourcepub fn with_capacity_and_hasher(
n: usize,
hash_builder: S,
) -> Result<Self, OutOfMemory>
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.
Sourcepub const fn with_hasher(hash_builder: S) -> Self
pub const fn with_hasher(hash_builder: S) -> Self
Same as [indexmap::IndexMap::with_hasher].
Sourcepub fn values_mut(&mut self) -> ValuesMut<'_, K, V> ⓘ
pub fn values_mut(&mut self) -> ValuesMut<'_, K, V> ⓘ
Same as [indexmap::IndexMap::values_mut].
Sourcepub fn into_values(self) -> IntoValues<K, V> ⓘ
pub fn into_values(self) -> IntoValues<K, V> ⓘ
Same as [indexmap::IndexMap::into_values].
Sourcepub fn drain<R>(&mut self, range: R) -> Drain<'_, K, V> ⓘwhere
R: RangeBounds<usize>,
pub fn drain<R>(&mut self, range: R) -> Drain<'_, K, V> ⓘwhere
R: RangeBounds<usize>,
Same as [indexmap::IndexMap::drain].
Sourcepub fn extract_if<F, R>(&mut self, range: R, pred: F) -> ExtractIf<'_, K, V, F> ⓘ
pub fn extract_if<F, R>(&mut self, range: R, pred: F) -> ExtractIf<'_, K, V, F> ⓘ
Same as [indexmap::IndexMap::extract_if].
Sourcepub fn split_off(&mut self, at: usize) -> Result<Self, OutOfMemory>
pub fn split_off(&mut self, at: usize) -> Result<Self, OutOfMemory>
Same as [indexmap::IndexMap::split_off] but returns an error on
allocation failure.
Sourcepub fn reserve(&mut self, additional: usize) -> Result<(), OutOfMemory>
pub fn reserve(&mut self, additional: usize) -> Result<(), OutOfMemory>
Same as [indexmap::IndexMap::reserve] but returns an error on
allocation failure.
Sourcepub fn reserve_exact(&mut self, additional: usize) -> Result<(), OutOfMemory>
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>
impl<K, V, S> IndexMap<K, V, S>
Sourcepub fn insert(&mut self, key: K, value: V) -> Result<Option<V>, OutOfMemory>
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.
Sourcepub fn insert_full(
&mut self,
key: K,
value: V,
) -> Result<(usize, Option<V>), OutOfMemory>
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.
Sourcepub fn insert_sorted(
&mut self,
key: K,
value: V,
) -> Result<(usize, Option<V>), OutOfMemory>where
K: Ord,
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.
Sourcepub fn insert_sorted_by<F>(
&mut self,
key: K,
value: V,
cmp: F,
) -> Result<(usize, Option<V>), OutOfMemory>
pub fn insert_sorted_by<F>( &mut self, key: K, value: V, cmp: F, ) -> Result<(usize, Option<V>), OutOfMemory>
Same as [indexmap::IndexMap::insert_sorted_by] but returns an error on
allocation failure.
Sourcepub fn insert_sorted_by_key<B, F>(
&mut self,
key: K,
value: V,
sort_key: F,
) -> Result<(usize, Option<V>), OutOfMemory>
pub fn insert_sorted_by_key<B, F>( &mut self, key: K, value: V, sort_key: F, ) -> Result<(usize, Option<V>), OutOfMemory>
Same as [indexmap::IndexMap::insert_sorted_by_key] but returns an
error on allocation failure.
Sourcepub fn insert_before(
&mut self,
index: usize,
key: K,
value: V,
) -> Result<(usize, Option<V>), OutOfMemory>
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.
Sourcepub fn shift_insert(
&mut self,
index: usize,
key: K,
value: V,
) -> Result<Option<V>, OutOfMemory>
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.
Sourcepub fn replace_index(&mut self, index: usize, key: K) -> Result<K, (usize, K)>
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,
impl<K, V, S> IndexMap<K, V, S>where
S: BuildHasher,
Sourcepub fn contains_key<Q>(&self, key: &Q) -> bool
pub fn contains_key<Q>(&self, key: &Q) -> bool
Same as [indexmap::IndexMap::contains_key].
Sourcepub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
pub fn get_key_value<Q>(&self, key: &Q) -> Option<(&K, &V)>
Same as [indexmap::IndexMap::get_key_value].
Sourcepub fn get_full<Q>(&self, key: &Q) -> Option<(usize, &K, &V)>
pub fn get_full<Q>(&self, key: &Q) -> Option<(usize, &K, &V)>
Same as [indexmap::IndexMap::get_full].
Sourcepub fn get_index_of<Q>(&self, key: &Q) -> Option<usize>
pub fn get_index_of<Q>(&self, key: &Q) -> Option<usize>
Same as [indexmap::IndexMap::get_index_of].
Sourcepub fn get_key_value_mut<Q>(&mut self, key: &Q) -> Option<(&K, &mut V)>
pub fn get_key_value_mut<Q>(&mut self, key: &Q) -> Option<(&K, &mut V)>
Same as [indexmap::IndexMap::get_key_value_mut].
Sourcepub fn get_full_mut<Q>(&mut self, key: &Q) -> Option<(usize, &K, &mut V)>
pub fn get_full_mut<Q>(&mut self, key: &Q) -> Option<(usize, &K, &mut V)>
Same as [indexmap::IndexMap::get_full_mut].
Sourcepub fn get_disjoint_mut<Q, const N: usize>(
&mut self,
keys: [&Q; N],
) -> [Option<&mut V>; N]
pub fn get_disjoint_mut<Q, const N: usize>( &mut self, keys: [&Q; N], ) -> [Option<&mut V>; N]
Same as [indexmap::IndexMap::get_disjoint_mut].
Sourcepub fn swap_remove<Q>(&mut self, key: &Q) -> Option<V>
pub fn swap_remove<Q>(&mut self, key: &Q) -> Option<V>
Same as [indexmap::IndexMap::swap_remove].
Sourcepub fn swap_remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
pub fn swap_remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
Same as [indexmap::IndexMap::swap_remove_entry].
Sourcepub fn swap_remove_full<Q>(&mut self, key: &Q) -> Option<(usize, K, V)>
pub fn swap_remove_full<Q>(&mut self, key: &Q) -> Option<(usize, K, V)>
Same as [indexmap::IndexMap::swap_remove_full].
Sourcepub fn shift_remove<Q>(&mut self, key: &Q) -> Option<V>
pub fn shift_remove<Q>(&mut self, key: &Q) -> Option<V>
Same as [indexmap::IndexMap::shift_remove].
Sourcepub fn shift_remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
pub fn shift_remove_entry<Q>(&mut self, key: &Q) -> Option<(K, V)>
Same as [indexmap::IndexMap::shift_remove_entry].
Source§impl<K, V, S> IndexMap<K, V, S>
impl<K, V, S> IndexMap<K, V, S>
Sourcepub fn sort_by_key<T, F>(&mut self, sort_key: F)
pub fn sort_by_key<T, F>(&mut self, sort_key: F)
Same as [indexmap::IndexMap::sort_by_key].
Sourcepub fn sort_unstable_keys(&mut self)where
K: Ord,
pub fn sort_unstable_keys(&mut self)where
K: Ord,
Same as [indexmap::IndexMap::sort_unstable_keys].
Sourcepub fn sort_unstable_by<F>(&mut self, cmp: F)
pub fn sort_unstable_by<F>(&mut self, cmp: F)
Same as [indexmap::IndexMap::sort_unstable_by].
Sourcepub fn sorted_unstable_by<F>(self, cmp: F) -> IntoIter<K, V> ⓘ
pub fn sorted_unstable_by<F>(self, cmp: F) -> IntoIter<K, V> ⓘ
Same as [indexmap::IndexMap::sorted_unstable_by].
Sourcepub fn sort_unstable_by_key<T, F>(&mut self, sort_key: F)
pub fn sort_unstable_by_key<T, F>(&mut self, sort_key: F)
Same as [indexmap::IndexMap::sort_unstable_by_key].
Sourcepub fn binary_search_keys(&self, x: &K) -> Result<usize, usize>where
K: Ord,
pub fn binary_search_keys(&self, x: &K) -> Result<usize, usize>where
K: Ord,
Same as [indexmap::IndexMap::binary_search_keys].
Sourcepub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
pub fn binary_search_by<'a, F>(&'a self, f: F) -> Result<usize, usize>
Same as [indexmap::IndexMap::binary_search_by].
Sourcepub fn binary_search_by_key<'a, B, F>(
&'a self,
b: &B,
f: F,
) -> Result<usize, usize>
pub fn binary_search_by_key<'a, B, F>( &'a self, b: &B, f: F, ) -> Result<usize, usize>
Same as [indexmap::IndexMap::binary_search_by_key].
Sourcepub fn is_sorted(&self) -> boolwhere
K: PartialOrd,
pub fn is_sorted(&self) -> boolwhere
K: PartialOrd,
Same as [indexmap::IndexMap::is_sorted].
Sourcepub fn is_sorted_by<'a, F>(&'a self, cmp: F) -> bool
pub fn is_sorted_by<'a, F>(&'a self, cmp: F) -> bool
Same as [indexmap::IndexMap::is_sorted_by].
Sourcepub fn is_sorted_by_key<'a, F, T>(&'a self, sort_key: F) -> bool
pub fn is_sorted_by_key<'a, F, T>(&'a self, sort_key: F) -> bool
Same as [indexmap::IndexMap::is_sorted_by_key].
Sourcepub fn partition_point<P>(&self, pred: P) -> usize
pub fn partition_point<P>(&self, pred: P) -> usize
Same as [indexmap::IndexMap::partition_point].
Sourcepub fn get_index(&self, index: usize) -> Option<(&K, &V)>
pub fn get_index(&self, index: usize) -> Option<(&K, &V)>
Same as [indexmap::IndexMap::get_index].
Sourcepub fn get_index_mut(&mut self, index: usize) -> Option<(&K, &mut V)>
pub fn get_index_mut(&mut self, index: usize) -> Option<(&K, &mut V)>
Same as [indexmap::IndexMap::get_index_mut].
Sourcepub fn get_disjoint_indices_mut<const N: usize>(
&mut self,
indices: [usize; N],
) -> Result<[(&K, &mut V); N], GetDisjointMutError>
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].
Sourcepub fn swap_remove_index(&mut self, index: usize) -> Option<(K, V)>
pub fn swap_remove_index(&mut self, index: usize) -> Option<(K, V)>
Same as [indexmap::IndexMap::swap_remove_index].
Sourcepub fn shift_remove_index(&mut self, index: usize) -> Option<(K, V)>
pub fn shift_remove_index(&mut self, index: usize) -> Option<(K, V)>
Same as [indexmap::IndexMap::shift_remove_index].
Sourcepub fn move_index(&mut self, from: usize, to: usize)
pub fn move_index(&mut self, from: usize, to: usize)
Same as [indexmap::IndexMap::move_index].
Sourcepub fn swap_indices(&mut self, a: usize, b: usize)
pub fn swap_indices(&mut self, a: usize, b: usize)
Same as [indexmap::IndexMap::swap_indices].
Trait Implementations§
Source§impl<'de, K, V> Deserialize<'de> for IndexMap<K, V>
impl<'de, K, V> Deserialize<'de> for IndexMap<K, V>
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<'a, K, V, S> IntoIterator for &'a IndexMap<K, V, S>
impl<'a, K, V, S> IntoIterator for &'a IndexMap<K, V, S>
Source§impl<'a, K, V, S> IntoIterator for &'a mut IndexMap<K, V, S>
impl<'a, K, V, S> IntoIterator for &'a mut IndexMap<K, V, S>
Source§impl<K, V, S> IntoIterator for IndexMap<K, V, S>
impl<K, V, S> IntoIterator for IndexMap<K, V, S>
Source§impl<K, V, S> TryClone for IndexMap<K, V, S>
impl<K, V, S> TryClone for IndexMap<K, V, S>
Source§fn try_clone(&self) -> Result<Self, OutOfMemory>
fn try_clone(&self) -> Result<Self, OutOfMemory>
self, returning an error if any allocation fails
during cloning.impl<K, V, S> Eq for IndexMap<K, V, S>
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>
impl<K, V, S> Sync for IndexMap<K, V, S>
impl<K, V, S> Unpin for IndexMap<K, V, S>
impl<K, V, S> UnwindSafe for IndexMap<K, V, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.