Struct Slice
struct Slice<K, V> { ... }
A dynamically-sized slice of key-value pairs in an IndexMap.
This supports indexed operations much like a [(K, V)] slice,
but not any hashed operations on the map keys.
Unlike IndexMap, Slice does consider the order for PartialEq
and Eq, and it also implements PartialOrd, Ord, and Hash.
Implementations
impl<K, V> Slice<K, V>
const fn new<'a>() -> &'a SelfReturns an empty slice.
fn new_mut<'a>() -> &'a mut SelfReturns an empty mutable slice.
const fn len(self: &Self) -> usizeReturn the number of key-value pairs in the map slice.
const fn is_empty(self: &Self) -> boolReturns true if the map slice contains no elements.
fn get_index(self: &Self, index: usize) -> Option<(&K, &V)>Get a key-value pair by index.
Valid indices are
0 <= index < self.len().fn get_index_mut(self: &mut Self, index: usize) -> Option<(&K, &mut V)>Get a key-value pair by index, with mutable access to the value.
Valid indices are
0 <= index < self.len().fn get_range<R: RangeBounds<usize>>(self: &Self, range: R) -> Option<&Self>Returns a slice of key-value pairs in the given range of indices.
Valid indices are
0 <= index < self.len().fn get_range_mut<R: RangeBounds<usize>>(self: &mut Self, range: R) -> Option<&mut Self>Returns a mutable slice of key-value pairs in the given range of indices.
Valid indices are
0 <= index < self.len().fn first(self: &Self) -> Option<(&K, &V)>Get the first key-value pair.
fn first_mut(self: &mut Self) -> Option<(&K, &mut V)>Get the first key-value pair, with mutable access to the value.
fn last(self: &Self) -> Option<(&K, &V)>Get the last key-value pair.
fn last_mut(self: &mut Self) -> Option<(&K, &mut V)>Get the last key-value pair, with mutable access to the value.
fn split_at(self: &Self, index: usize) -> (&Self, &Self)Divides one slice into two at an index.
Panics if
index > len.fn split_at_mut(self: &mut Self, index: usize) -> (&mut Self, &mut Self)Divides one mutable slice into two at an index.
Panics if
index > len.fn split_first(self: &Self) -> Option<((&K, &V), &Self)>Returns the first key-value pair and the rest of the slice, or
Noneif it is empty.fn split_first_mut(self: &mut Self) -> Option<((&K, &mut V), &mut Self)>Returns the first key-value pair and the rest of the slice, with mutable access to the value, or
Noneif it is empty.fn split_last(self: &Self) -> Option<((&K, &V), &Self)>Returns the last key-value pair and the rest of the slice, or
Noneif it is empty.fn split_last_mut(self: &mut Self) -> Option<((&K, &mut V), &mut Self)>Returns the last key-value pair and the rest of the slice, with mutable access to the value, or
Noneif it is empty.fn iter(self: &Self) -> Iter<'_, K, V>Return an iterator over the key-value pairs of the map slice.
fn iter_mut(self: &mut Self) -> IterMut<'_, K, V>Return an iterator over the key-value pairs of the map slice.
fn keys(self: &Self) -> Keys<'_, K, V>Return an iterator over the keys of the map slice.
fn into_keys(self: Box<Self>) -> IntoKeys<K, V>Return an owning iterator over the keys of the map slice.
fn values(self: &Self) -> Values<'_, K, V>Return an iterator over the values of the map slice.
fn values_mut(self: &mut Self) -> ValuesMut<'_, K, V>Return an iterator over mutable references to the the values of the map slice.
fn into_values(self: Box<Self>) -> IntoValues<K, V>Return an owning iterator over the values of the map slice.
fn binary_search_keys(self: &Self, x: &K) -> Result<usize, usize> where K: OrdSearch over a sorted map for a key.
Returns the position where that key is present, or the position where it can be inserted to maintain the sort. See
slice::binary_searchfor more details.Computes in O(log(n)) time, which is notably less scalable than looking the key up in the map this is a slice from using
IndexMap::get_index_of, but this can also position missing keys.fn binary_search_by<'a, F>(self: &'a Self, f: F) -> Result<usize, usize> where F: FnMut(&'a K, &'a V) -> OrderingSearch over a sorted map with a comparator function.
Returns the position where that value is present, or the position where it can be inserted to maintain the sort. See
slice::binary_search_byfor more details.Computes in O(log(n)) time.
fn binary_search_by_key<'a, B, F>(self: &'a Self, b: &B, f: F) -> Result<usize, usize> where F: FnMut(&'a K, &'a V) -> B, B: OrdSearch over a sorted map with an extraction function.
Returns the position where that value is present, or the position where it can be inserted to maintain the sort. See
slice::binary_search_by_keyfor more details.Computes in O(log(n)) time.
fn partition_point<P>(self: &Self, pred: P) -> usize where P: FnMut(&K, &V) -> boolReturns the index of the partition point of a sorted map according to the given predicate (the index of the first element of the second partition).
See
slice::partition_pointfor more details.Computes in O(log(n)) time.
fn get_disjoint_mut<N: usize>(self: &mut Self, indices: [usize; N]) -> Result<[(&K, &mut V); N], GetDisjointMutError>Get an array of
Nkey-value pairs byNindicesValid indices are 0 <= index < self.len() and each index needs to be unique.
impl<K, V> Freeze for Slice<K, V>
impl<K, V> Index for Slice<K, V>
fn index(self: &Self, range: Range<usize>) -> &Self
impl<K, V> Index for Slice<K, V>
fn index(self: &Self, range: RangeFull) -> &Self
impl<K, V> Index for Slice<K, V>
fn index(self: &Self, range: RangeTo<usize>) -> &Self
impl<K, V> Index for Slice<K, V>
fn index(self: &Self, range: (Bound<usize>, Bound<usize>)) -> &Self
impl<K, V> Index for Slice<K, V>
fn index(self: &Self, index: usize) -> &V
impl<K, V> Index for Slice<K, V>
fn index(self: &Self, range: RangeFrom<usize>) -> &Self
impl<K, V> Index for Slice<K, V>
fn index(self: &Self, range: RangeInclusive<usize>) -> &Self
impl<K, V> Index for Slice<K, V>
fn index(self: &Self, range: RangeToInclusive<usize>) -> &Self
impl<K, V> IndexMut for Slice<K, V>
fn index_mut(self: &mut Self, range: Range<usize>) -> &mut Self
impl<K, V> IndexMut for Slice<K, V>
fn index_mut(self: &mut Self, range: RangeFull) -> &mut Self
impl<K, V> IndexMut for Slice<K, V>
fn index_mut(self: &mut Self, range: RangeTo<usize>) -> &mut Self
impl<K, V> IndexMut for Slice<K, V>
fn index_mut(self: &mut Self, range: (Bound<usize>, Bound<usize>)) -> &mut Self
impl<K, V> IndexMut for Slice<K, V>
fn index_mut(self: &mut Self, index: usize) -> &mut V
impl<K, V> IndexMut for Slice<K, V>
fn index_mut(self: &mut Self, range: RangeFrom<usize>) -> &mut Self
impl<K, V> IndexMut for Slice<K, V>
fn index_mut(self: &mut Self, range: RangeInclusive<usize>) -> &mut Self
impl<K, V> IndexMut for Slice<K, V>
fn index_mut(self: &mut Self, range: RangeToInclusive<usize>) -> &mut Self
impl<K, V> RefUnwindSafe for Slice<K, V>
impl<K, V> Send for Slice<K, V>
impl<K, V> Sized for Slice<K, V>
impl<K, V> Sync for Slice<K, V>
impl<K, V> Unpin for Slice<K, V>
impl<K, V> UnsafeUnpin for Slice<K, V>
impl<K, V> UnwindSafe for Slice<K, V>
impl<K, V, K2, V2> PartialEq for Slice<K, V>
fn eq(self: &Self, other: &[(K2, V2)]) -> bool
impl<K, V, K2, V2> PartialEq for Slice<K, V>
fn eq(self: &Self, other: &Slice<K2, V2>) -> bool
impl<K, V, K2, V2, N: usize> PartialEq for Slice<K, V>
fn eq(self: &Self, other: &[(K2, V2); N]) -> bool
impl<K: Eq, V: Eq> Eq for Slice<K, V>
impl<K: Hash, V: Hash> Hash for Slice<K, V>
fn hash<H: Hasher>(self: &Self, state: &mut H)
impl<K: Ord, V: Ord> Ord for Slice<K, V>
fn cmp(self: &Self, other: &Self) -> Ordering
impl<K: PartialOrd, V: PartialOrd> PartialOrd for Slice<K, V>
fn partial_cmp(self: &Self, other: &Self) -> Option<Ordering>
impl<K: fmt::Debug, V: fmt::Debug> Debug for Slice<K, V>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<Q, K> Comparable for Slice<K, V>
fn compare(self: &Self, key: &K) -> Ordering
impl<Q, K> Equivalent for Slice<K, V>
fn equivalent(self: &Self, key: &K) -> bool
impl<Q, K> Equivalent for Slice<K, V>
fn equivalent(self: &Self, key: &K) -> bool
impl<T> Any for Slice<K, V>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Slice<K, V>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Slice<K, V>
fn borrow_mut(self: &mut Self) -> &mut T