pub struct TryIndexMap<K, V, S = RandomState> { /* private fields */ }Expand description
A wrapper around indexmap::IndexMap that only provides fallible
allocation.
Implementations§
Source§impl<K, V> TryIndexMap<K, V>
impl<K, V> TryIndexMap<K, V>
Sourcepub fn new() -> Self
pub fn new() -> Self
Same as indexmap::IndexMap::new.
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> TryIndexMap<K, V, S>
impl<K, V, S> TryIndexMap<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 capacity(&self) -> usize
pub fn capacity(&self) -> usize
Same as indexmap::IndexMap::capacity.
Sourcepub fn hasher(&self) -> &S
pub fn hasher(&self) -> &S
Same as indexmap::IndexMap::hasher.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
Same as indexmap::IndexMap::len.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Same as indexmap::IndexMap::is_empty.
Sourcepub fn iter(&self) -> Iter<'_, K, V> ⓘ
pub fn iter(&self) -> Iter<'_, K, V> ⓘ
Same as indexmap::IndexMap::iter.
Sourcepub fn iter_mut(&mut self) -> IterMut<'_, K, V> ⓘ
pub fn iter_mut(&mut self) -> IterMut<'_, K, V> ⓘ
Same as indexmap::IndexMap::iter_mut.
Sourcepub fn keys(&self) -> Keys<'_, K, V> ⓘ
pub fn keys(&self) -> Keys<'_, K, V> ⓘ
Same as indexmap::IndexMap::keys.
Sourcepub fn into_keys(self) -> IntoKeys<K, V> ⓘ
pub fn into_keys(self) -> IntoKeys<K, V> ⓘ
Same as indexmap::IndexMap::into_keys.
Sourcepub fn values(&self) -> Values<'_, K, V> ⓘ
pub fn values(&self) -> Values<'_, K, V> ⓘ
Same as indexmap::IndexMap::values.
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 clear(&mut self)
pub fn clear(&mut self)
Same as indexmap::IndexMap::clear.
Sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Same as indexmap::IndexMap::truncate.
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> TryIndexMap<K, V, S>
impl<K, V, S> TryIndexMap<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> TryIndexMap<K, V, S>where
S: BuildHasher,
impl<K, V, S> TryIndexMap<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_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)>
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)>
Sourcepub fn shift_remove_full<Q>(&mut self, key: &Q) -> Option<(usize, K, V)>
pub fn shift_remove_full<Q>(&mut self, key: &Q) -> Option<(usize, K, V)>
Source§impl<K, V, S> TryIndexMap<K, V, S>
impl<K, V, S> TryIndexMap<K, V, S>
Sourcepub fn pop(&mut self) -> Option<(K, V)>
pub fn pop(&mut self) -> Option<(K, V)>
Same as indexmap::IndexMap::pop.
Sourcepub fn retain<F>(&mut self, keep: F)
pub fn retain<F>(&mut self, keep: F)
Same as indexmap::IndexMap::retain.
Sourcepub fn sort_keys(&mut self)where
K: Ord,
pub fn sort_keys(&mut self)where
K: Ord,
Same as indexmap::IndexMap::sort_keys.
Sourcepub fn sort_by<F>(&mut self, cmp: F)
pub fn sort_by<F>(&mut self, cmp: F)
Same as indexmap::IndexMap::sort_by.
Sourcepub fn sorted_by<F>(self, cmp: F) -> IntoIter<K, V> ⓘ
pub fn sorted_by<F>(self, cmp: F) -> IntoIter<K, V> ⓘ
Same as indexmap::IndexMap::sorted_by.
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,
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> ⓘ
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)
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 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 reverse(&mut self)
pub fn reverse(&mut self)
Same as indexmap::IndexMap::reverse.
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>
Sourcepub fn swap_remove_index(&mut self, index: usize) -> Option<(K, V)>
pub fn swap_remove_index(&mut self, index: usize) -> Option<(K, V)>
Sourcepub fn shift_remove_index(&mut self, index: usize) -> Option<(K, V)>
pub fn shift_remove_index(&mut self, index: usize) -> Option<(K, V)>
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<K, V, S> Debug for TryIndexMap<K, V, S>
impl<K, V, S> Debug for TryIndexMap<K, V, S>
Source§impl<K, V, S> Default for TryIndexMap<K, V, S>where
S: Default,
impl<K, V, S> Default for TryIndexMap<K, V, S>where
S: Default,
Source§impl<'de, K, V> Deserialize<'de> for TryIndexMap<K, V>
impl<'de, K, V> Deserialize<'de> for TryIndexMap<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<K, V, S> From<IndexMap<K, V, S>> for TryIndexMap<K, V, S>
impl<K, V, S> From<IndexMap<K, V, S>> for TryIndexMap<K, V, S>
Source§impl<K, V, S> From<TryIndexMap<K, V, S>> for IndexMap<K, V, S>
impl<K, V, S> From<TryIndexMap<K, V, S>> for IndexMap<K, V, S>
Source§fn from(map: TryIndexMap<K, V, S>) -> Self
fn from(map: TryIndexMap<K, V, S>) -> Self
Source§impl<K, V, Q, S> Index<&Q> for TryIndexMap<K, V, S>
impl<K, V, Q, S> Index<&Q> for TryIndexMap<K, V, S>
Source§impl<K, V, S> Index<usize> for TryIndexMap<K, V, S>
impl<K, V, S> Index<usize> for TryIndexMap<K, V, S>
Source§impl<K, V, Q, S> IndexMut<&Q> for TryIndexMap<K, V, S>
impl<K, V, Q, S> IndexMut<&Q> for TryIndexMap<K, V, S>
Source§impl<K, V, S> IndexMut<usize> for TryIndexMap<K, V, S>
impl<K, V, S> IndexMut<usize> for TryIndexMap<K, V, S>
Source§impl<'a, K, V, S> IntoIterator for &'a TryIndexMap<K, V, S>
impl<'a, K, V, S> IntoIterator for &'a TryIndexMap<K, V, S>
Source§impl<'a, K, V, S> IntoIterator for &'a mut TryIndexMap<K, V, S>
impl<'a, K, V, S> IntoIterator for &'a mut TryIndexMap<K, V, S>
Source§impl<K, V, S> IntoIterator for TryIndexMap<K, V, S>
impl<K, V, S> IntoIterator for TryIndexMap<K, V, S>
Source§impl<K, V1, S1, V2, S2> PartialEq<TryIndexMap<K, V2, S2>> for TryIndexMap<K, V1, S1>
impl<K, V1, S1, V2, S2> PartialEq<TryIndexMap<K, V2, S2>> for TryIndexMap<K, V1, S1>
Source§impl<K, V, H> Serialize for TryIndexMap<K, V, H>
impl<K, V, H> Serialize for TryIndexMap<K, V, H>
Source§impl<K, V, S> TryClone for TryIndexMap<K, V, S>
impl<K, V, S> TryClone for TryIndexMap<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.Source§fn clone_panic_on_oom(&self) -> Self
fn clone_panic_on_oom(&self) -> Self
self, panicking on allocation failure.impl<K, V, S> Eq for TryIndexMap<K, V, S>
Auto Trait Implementations§
impl<K, V, S> Freeze for TryIndexMap<K, V, S>where
S: Freeze,
impl<K, V, S> RefUnwindSafe for TryIndexMap<K, V, S>
impl<K, V, S> Send for TryIndexMap<K, V, S>
impl<K, V, S> Sync for TryIndexMap<K, V, S>
impl<K, V, S> Unpin for TryIndexMap<K, V, S>
impl<K, V, S> UnsafeUnpin for TryIndexMap<K, V, S>where
S: UnsafeUnpin,
impl<K, V, S> UnwindSafe for TryIndexMap<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
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> TryToOwned for Twhere
T: TryClone,
impl<T> TryToOwned for Twhere
T: TryClone,
Source§fn try_to_owned(&self) -> Result<<T as TryToOwned>::Owned, OutOfMemory>
fn try_to_owned(&self) -> Result<<T as TryToOwned>::Owned, OutOfMemory>
self.