Struct otter_nodejs_tests::IndexSet
source · [−]pub struct IndexSet<T, S = RandomState> { /* private fields */ }Expand description
A hash set where the iteration order of the values is independent of their hash values.
The interface is closely compatible with the standard HashSet, but also
has additional features.
Order
The values have a consistent order that is determined by the sequence of insertion and removal calls on the set. The order does not depend on the values or the hash function at all. Note that insertion order and value are not affected if a re-insertion is attempted once an element is already present.
All iterators traverse the set in order. Set operation iterators like
union produce a concatenated order, as do their matching “bitwise”
operators. See their documentation for specifics.
The insertion order is preserved, with notable exceptions like the
.remove() or .swap_remove() methods. Methods such as .sort_by() of
course result in a new order, depending on the sorting order.
Indices
The values are indexed in a compact range without holes in the range
0..self.len(). For example, the method .get_full looks up the index for
a value, and the method .get_index looks up the value by index.
Examples
use indexmap::IndexSet;
// Collects which letters appear in a sentence.
let letters: IndexSet<_> = "a short treatise on fungi".chars().collect();
assert!(letters.contains(&'s'));
assert!(letters.contains(&'t'));
assert!(letters.contains(&'u'));
assert!(!letters.contains(&'y'));Implementations
sourceimpl<T> IndexSet<T, RandomState>
impl<T> IndexSet<T, RandomState>
sourcepub fn new() -> IndexSet<T, RandomState>
pub fn new() -> IndexSet<T, RandomState>
Create a new set. (Does not allocate.)
sourcepub fn with_capacity(n: usize) -> IndexSet<T, RandomState>
pub fn with_capacity(n: usize) -> IndexSet<T, RandomState>
Create a new set with capacity for n elements.
(Does not allocate if n is zero.)
Computes in O(n) time.
sourceimpl<T, S> IndexSet<T, S>
impl<T, S> IndexSet<T, S>
sourcepub fn with_capacity_and_hasher(n: usize, hash_builder: S) -> IndexSet<T, S>
pub fn with_capacity_and_hasher(n: usize, hash_builder: S) -> IndexSet<T, S>
Create a new set with capacity for n elements.
(Does not allocate if n is zero.)
Computes in O(n) time.
sourcepub const fn with_hasher(hash_builder: S) -> IndexSet<T, S>
pub const fn with_hasher(hash_builder: S) -> IndexSet<T, S>
Create a new set with hash_builder.
This function is const, so it
can be called in static contexts.
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true if the set contains no elements.
Computes in O(1) time.
sourcepub fn iter(&self) -> Iter<'_, T>ⓘNotable traits for Iter<'a, T>impl<'a, T> Iterator for Iter<'a, T> type Item = &'a T;
pub fn iter(&self) -> Iter<'_, T>ⓘNotable traits for Iter<'a, T>impl<'a, T> Iterator for Iter<'a, T> type Item = &'a T;
Return an iterator over the values of the set, in their order
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Remove all elements in the set, while preserving its capacity.
Computes in O(n) time.
sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Shortens the set, keeping the first len elements and dropping the rest.
If len is greater than the set’s current length, this has no effect.
sourcepub fn drain<R>(&mut self, range: R) -> Drain<'_, T>ⓘNotable traits for Drain<'_, T>impl<'_, T> Iterator for Drain<'_, T> type Item = T; where
R: RangeBounds<usize>,
pub fn drain<R>(&mut self, range: R) -> Drain<'_, T>ⓘNotable traits for Drain<'_, T>impl<'_, T> Iterator for Drain<'_, T> type Item = T; where
R: RangeBounds<usize>,
Clears the IndexSet in the given index range, returning those values
as a drain iterator.
The range may be any type that implements RangeBounds<usize>,
including all of the std::ops::Range* types, or even a tuple pair of
Bound start and end values. To drain the set entirely, use RangeFull
like set.drain(..).
This shifts down all entries following the drained range to fill the gap, and keeps the allocated memory for reuse.
Panics if the starting point is greater than the end point or if the end point is greater than the length of the set.
sourcepub fn split_off(&mut self, at: usize) -> IndexSet<T, S> where
S: Clone,
pub fn split_off(&mut self, at: usize) -> IndexSet<T, S> where
S: Clone,
Splits the collection into two at the given index.
Returns a newly allocated set containing the elements in the range
[at, len). After the call, the original set will be left containing
the elements [0, at) with its previous capacity unchanged.
Panics if at > len.
sourceimpl<T, S> IndexSet<T, S> where
T: Hash + Eq,
S: BuildHasher,
impl<T, S> IndexSet<T, S> where
T: Hash + Eq,
S: BuildHasher,
sourcepub fn reserve(&mut self, additional: usize)
pub fn reserve(&mut self, additional: usize)
Reserve capacity for additional more values.
Computes in O(n) time.
sourcepub fn shrink_to_fit(&mut self)
pub fn shrink_to_fit(&mut self)
Shrink the capacity of the set as much as possible.
Computes in O(n) time.
sourcepub fn insert(&mut self, value: T) -> bool
pub fn insert(&mut self, value: T) -> bool
Insert the value into the set.
If an equivalent item already exists in the set, it returns
false leaving the original value in the set and without
altering its insertion order. Otherwise, it inserts the new
item and returns true.
Computes in O(1) time (amortized average).
sourcepub fn insert_full(&mut self, value: T) -> (usize, bool)
pub fn insert_full(&mut self, value: T) -> (usize, bool)
Insert the value into the set, and get its index.
If an equivalent item already exists in the set, it returns
the index of the existing item and false, leaving the
original value in the set and without altering its insertion
order. Otherwise, it inserts the new item and returns the index
of the inserted item and true.
Computes in O(1) time (amortized average).
sourcepub fn difference<S2>(
&'a self,
other: &'a IndexSet<T, S2>
) -> Difference<'a, T, S2>ⓘNotable traits for Difference<'a, T, S>impl<'a, T, S> Iterator for Difference<'a, T, S> where
T: Eq + Hash,
S: BuildHasher, type Item = &'a T; where
S2: BuildHasher,
pub fn difference<S2>(
&'a self,
other: &'a IndexSet<T, S2>
) -> Difference<'a, T, S2>ⓘNotable traits for Difference<'a, T, S>impl<'a, T, S> Iterator for Difference<'a, T, S> where
T: Eq + Hash,
S: BuildHasher, type Item = &'a T; where
S2: BuildHasher,
T: Eq + Hash,
S: BuildHasher, type Item = &'a T;
Return an iterator over the values that are in self but not other.
Values are produced in the same order that they appear in self.
sourcepub fn symmetric_difference<S2>(
&'a self,
other: &'a IndexSet<T, S2>
) -> SymmetricDifference<'a, T, S, S2>ⓘNotable traits for SymmetricDifference<'a, T, S1, S2>impl<'a, T, S1, S2> Iterator for SymmetricDifference<'a, T, S1, S2> where
T: Eq + Hash,
S1: BuildHasher,
S2: BuildHasher, type Item = &'a T; where
S2: BuildHasher,
pub fn symmetric_difference<S2>(
&'a self,
other: &'a IndexSet<T, S2>
) -> SymmetricDifference<'a, T, S, S2>ⓘNotable traits for SymmetricDifference<'a, T, S1, S2>impl<'a, T, S1, S2> Iterator for SymmetricDifference<'a, T, S1, S2> where
T: Eq + Hash,
S1: BuildHasher,
S2: BuildHasher, type Item = &'a T; where
S2: BuildHasher,
T: Eq + Hash,
S1: BuildHasher,
S2: BuildHasher, type Item = &'a T;
Return an iterator over the values that are in self or other,
but not in both.
Values from self are produced in their original order, followed by
values from other in their original order.
sourcepub fn intersection<S2>(
&'a self,
other: &'a IndexSet<T, S2>
) -> Intersection<'a, T, S2>ⓘNotable traits for Intersection<'a, T, S>impl<'a, T, S> Iterator for Intersection<'a, T, S> where
T: Eq + Hash,
S: BuildHasher, type Item = &'a T; where
S2: BuildHasher,
pub fn intersection<S2>(
&'a self,
other: &'a IndexSet<T, S2>
) -> Intersection<'a, T, S2>ⓘNotable traits for Intersection<'a, T, S>impl<'a, T, S> Iterator for Intersection<'a, T, S> where
T: Eq + Hash,
S: BuildHasher, type Item = &'a T; where
S2: BuildHasher,
T: Eq + Hash,
S: BuildHasher, type Item = &'a T;
Return an iterator over the values that are in both self and other.
Values are produced in the same order that they appear in self.
sourcepub fn union<S2>(&'a self, other: &'a IndexSet<T, S2>) -> Union<'a, T, S>ⓘNotable traits for Union<'a, T, S>impl<'a, T, S> Iterator for Union<'a, T, S> where
T: Eq + Hash,
S: BuildHasher, type Item = &'a T; where
S2: BuildHasher,
pub fn union<S2>(&'a self, other: &'a IndexSet<T, S2>) -> Union<'a, T, S>ⓘNotable traits for Union<'a, T, S>impl<'a, T, S> Iterator for Union<'a, T, S> where
T: Eq + Hash,
S: BuildHasher, type Item = &'a T; where
S2: BuildHasher,
T: Eq + Hash,
S: BuildHasher, type Item = &'a T;
Return an iterator over all values that are in self or other.
Values from self are produced in their original order, followed by
values that are unique to other in their original order.
sourcepub fn contains<Q>(&self, value: &Q) -> bool where
Q: Hash + Equivalent<T> + ?Sized,
pub fn contains<Q>(&self, value: &Q) -> bool where
Q: Hash + Equivalent<T> + ?Sized,
Return true if an equivalent to value exists in the set.
Computes in O(1) time (average).
sourcepub fn get<Q>(&self, value: &Q) -> Option<&T> where
Q: Hash + Equivalent<T> + ?Sized,
pub fn get<Q>(&self, value: &Q) -> Option<&T> where
Q: Hash + Equivalent<T> + ?Sized,
Return a reference to the value stored in the set, if it is present,
else None.
Computes in O(1) time (average).
sourcepub fn get_full<Q>(&self, value: &Q) -> Option<(usize, &T)> where
Q: Hash + Equivalent<T> + ?Sized,
pub fn get_full<Q>(&self, value: &Q) -> Option<(usize, &T)> where
Q: Hash + Equivalent<T> + ?Sized,
Return item index and value
sourcepub fn get_index_of<Q>(&self, value: &Q) -> Option<usize> where
Q: Hash + Equivalent<T> + ?Sized,
pub fn get_index_of<Q>(&self, value: &Q) -> Option<usize> where
Q: Hash + Equivalent<T> + ?Sized,
Return item index, if it exists in the set
sourcepub fn replace(&mut self, value: T) -> Option<T>
pub fn replace(&mut self, value: T) -> Option<T>
Adds a value to the set, replacing the existing value, if any, that is equal to the given one, without altering its insertion order. Returns the replaced value.
Computes in O(1) time (average).
sourcepub fn replace_full(&mut self, value: T) -> (usize, Option<T>)
pub fn replace_full(&mut self, value: T) -> (usize, Option<T>)
Adds a value to the set, replacing the existing value, if any, that is equal to the given one, without altering its insertion order. Returns the index of the item and its replaced value.
Computes in O(1) time (average).
sourcepub fn remove<Q>(&mut self, value: &Q) -> bool where
Q: Hash + Equivalent<T> + ?Sized,
pub fn remove<Q>(&mut self, value: &Q) -> bool where
Q: Hash + Equivalent<T> + ?Sized,
Remove the value from the set, and return true if it was present.
NOTE: This is equivalent to .swap_remove(value), if you want
to preserve the order of the values in the set, use .shift_remove(value).
Computes in O(1) time (average).
sourcepub fn swap_remove<Q>(&mut self, value: &Q) -> bool where
Q: Hash + Equivalent<T> + ?Sized,
pub fn swap_remove<Q>(&mut self, value: &Q) -> bool where
Q: Hash + Equivalent<T> + ?Sized,
Remove the value from the set, and return true if it was present.
Like Vec::swap_remove, the value is removed by swapping it with the
last element of the set and popping it off. This perturbs
the position of what used to be the last element!
Return false if value was not in the set.
Computes in O(1) time (average).
sourcepub fn shift_remove<Q>(&mut self, value: &Q) -> bool where
Q: Hash + Equivalent<T> + ?Sized,
pub fn shift_remove<Q>(&mut self, value: &Q) -> bool where
Q: Hash + Equivalent<T> + ?Sized,
Remove the value from the set, and return true if it was present.
Like Vec::remove, the value is removed by shifting all of the
elements that follow it, preserving their relative order.
This perturbs the index of all of those elements!
Return false if value was not in the set.
Computes in O(n) time (average).
sourcepub fn take<Q>(&mut self, value: &Q) -> Option<T> where
Q: Hash + Equivalent<T> + ?Sized,
pub fn take<Q>(&mut self, value: &Q) -> Option<T> where
Q: Hash + Equivalent<T> + ?Sized,
Removes and returns the value in the set, if any, that is equal to the given one.
NOTE: This is equivalent to .swap_take(value), if you need to
preserve the order of the values in the set, use .shift_take(value)
instead.
Computes in O(1) time (average).
sourcepub fn swap_take<Q>(&mut self, value: &Q) -> Option<T> where
Q: Hash + Equivalent<T> + ?Sized,
pub fn swap_take<Q>(&mut self, value: &Q) -> Option<T> where
Q: Hash + Equivalent<T> + ?Sized,
Removes and returns the value in the set, if any, that is equal to the given one.
Like Vec::swap_remove, the value is removed by swapping it with the
last element of the set and popping it off. This perturbs
the position of what used to be the last element!
Return None if value was not in the set.
Computes in O(1) time (average).
sourcepub fn shift_take<Q>(&mut self, value: &Q) -> Option<T> where
Q: Hash + Equivalent<T> + ?Sized,
pub fn shift_take<Q>(&mut self, value: &Q) -> Option<T> where
Q: Hash + Equivalent<T> + ?Sized,
Removes and returns the value in the set, if any, that is equal to the given one.
Like Vec::remove, the value is removed by shifting all of the
elements that follow it, preserving their relative order.
This perturbs the index of all of those elements!
Return None if value was not in the set.
Computes in O(n) time (average).
sourcepub fn swap_remove_full<Q>(&mut self, value: &Q) -> Option<(usize, T)> where
Q: Hash + Equivalent<T> + ?Sized,
pub fn swap_remove_full<Q>(&mut self, value: &Q) -> Option<(usize, T)> where
Q: Hash + Equivalent<T> + ?Sized,
Remove the value from the set return it and the index it had.
Like Vec::swap_remove, the value is removed by swapping it with the
last element of the set and popping it off. This perturbs
the position of what used to be the last element!
Return None if value was not in the set.
sourcepub fn shift_remove_full<Q>(&mut self, value: &Q) -> Option<(usize, T)> where
Q: Hash + Equivalent<T> + ?Sized,
pub fn shift_remove_full<Q>(&mut self, value: &Q) -> Option<(usize, T)> where
Q: Hash + Equivalent<T> + ?Sized,
Remove the value from the set return it and the index it had.
Like Vec::remove, the value is removed by shifting all of the
elements that follow it, preserving their relative order.
This perturbs the index of all of those elements!
Return None if value was not in the set.
sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Remove the last value
This preserves the order of the remaining elements.
Computes in O(1) time (average).
sourcepub fn retain<F>(&mut self, keep: F) where
F: FnMut(&T) -> bool,
pub fn retain<F>(&mut self, keep: F) where
F: FnMut(&T) -> bool,
Scan through each value in the set and keep those where the
closure keep returns true.
The elements are visited in order, and remaining elements keep their order.
Computes in O(n) time (average).
sourcepub fn sort(&mut self) where
T: Ord,
pub fn sort(&mut self) where
T: Ord,
Sort the set’s values by their default ordering.
See sort_by for details.
sourcepub fn sort_by<F>(&mut self, cmp: F) where
F: FnMut(&T, &T) -> Ordering,
pub fn sort_by<F>(&mut self, cmp: F) where
F: FnMut(&T, &T) -> Ordering,
Sort the set’s values in place using the comparison function cmp.
Computes in O(n log n) time and O(n) space. The sort is stable.
sourcepub fn sorted_by<F>(self, cmp: F) -> IntoIter<T>ⓘNotable traits for IntoIter<T>impl<T> Iterator for IntoIter<T> type Item = T; where
F: FnMut(&T, &T) -> Ordering,
pub fn sorted_by<F>(self, cmp: F) -> IntoIter<T>ⓘNotable traits for IntoIter<T>impl<T> Iterator for IntoIter<T> type Item = T; where
F: FnMut(&T, &T) -> Ordering,
Sort the values of the set and return a by-value iterator of the values with the result.
The sort is stable.
sourcepub fn sort_unstable(&mut self) where
T: Ord,
pub fn sort_unstable(&mut self) where
T: Ord,
Sort the set’s values by their default ordering.
See sort_unstable_by for details.
sourcepub fn sort_unstable_by<F>(&mut self, cmp: F) where
F: FnMut(&T, &T) -> Ordering,
pub fn sort_unstable_by<F>(&mut self, cmp: F) where
F: FnMut(&T, &T) -> Ordering,
Sort the set’s values in place using the comparison funtion cmp.
Computes in O(n log n) time. The sort is unstable.
sourceimpl<T, S> IndexSet<T, S>
impl<T, S> IndexSet<T, S>
sourcepub fn get_index(&self, index: usize) -> Option<&T>
pub fn get_index(&self, index: usize) -> Option<&T>
Get a value by index
Valid indices are 0 <= index < self.len()
Computes in O(1) time.
sourcepub fn swap_remove_index(&mut self, index: usize) -> Option<T>
pub fn swap_remove_index(&mut self, index: usize) -> Option<T>
Remove the value by index
Valid indices are 0 <= index < self.len()
Like Vec::swap_remove, the value is removed by swapping it with the
last element of the set and popping it off. This perturbs
the position of what used to be the last element!
Computes in O(1) time (average).
sourcepub fn shift_remove_index(&mut self, index: usize) -> Option<T>
pub fn shift_remove_index(&mut self, index: usize) -> Option<T>
Remove the value by index
Valid indices are 0 <= index < self.len()
Like Vec::remove, the value is removed by shifting all of the
elements that follow it, preserving their relative order.
This perturbs the index of all of those elements!
Computes in O(n) time (average).
sourcepub fn swap_indices(&mut self, a: usize, b: usize)
pub fn swap_indices(&mut self, a: usize, b: usize)
Swaps the position of two values in the set.
Panics if a or b are out of bounds.
sourceimpl<T, S> IndexSet<T, S> where
T: Eq + Hash,
S: BuildHasher,
impl<T, S> IndexSet<T, S> where
T: Eq + Hash,
S: BuildHasher,
sourcepub fn is_disjoint<S2>(&self, other: &IndexSet<T, S2>) -> bool where
S2: BuildHasher,
pub fn is_disjoint<S2>(&self, other: &IndexSet<T, S2>) -> bool where
S2: BuildHasher,
Returns true if self has no elements in common with other.
sourcepub fn is_subset<S2>(&self, other: &IndexSet<T, S2>) -> bool where
S2: BuildHasher,
pub fn is_subset<S2>(&self, other: &IndexSet<T, S2>) -> bool where
S2: BuildHasher,
Returns true if all elements of self are contained in other.
sourcepub fn is_superset<S2>(&self, other: &IndexSet<T, S2>) -> bool where
S2: BuildHasher,
pub fn is_superset<S2>(&self, other: &IndexSet<T, S2>) -> bool where
S2: BuildHasher,
Returns true if all elements of other are contained in self.
Trait Implementations
sourceimpl<'_, '_, T, S1, S2> BitAnd<&'_ IndexSet<T, S2>> for &'_ IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
impl<'_, '_, T, S1, S2> BitAnd<&'_ IndexSet<T, S2>> for &'_ IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
sourceimpl<'_, '_, T, S1, S2> BitOr<&'_ IndexSet<T, S2>> for &'_ IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
impl<'_, '_, T, S1, S2> BitOr<&'_ IndexSet<T, S2>> for &'_ IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
sourceimpl<'_, '_, T, S1, S2> BitXor<&'_ IndexSet<T, S2>> for &'_ IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
impl<'_, '_, T, S1, S2> BitXor<&'_ IndexSet<T, S2>> for &'_ IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
sourceimpl<'de, T, S> Deserialize<'de> for IndexSet<T, S> where
T: Deserialize<'de> + Eq + Hash,
S: Default + BuildHasher,
impl<'de, T, S> Deserialize<'de> for IndexSet<T, S> where
T: Deserialize<'de> + Eq + Hash,
S: Default + BuildHasher,
Requires crate feature "serde" or "serde-1"
sourcefn deserialize<D>(
deserializer: D
) -> Result<IndexSet<T, S>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<IndexSet<T, S>, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<'a, T, S> Extend<&'a T> for IndexSet<T, S> where
T: 'a + Hash + Eq + Copy,
S: BuildHasher,
impl<'a, T, S> Extend<&'a T> for IndexSet<T, S> where
T: 'a + Hash + Eq + Copy,
S: BuildHasher,
sourcefn extend<I>(&mut self, iterable: I) where
I: IntoIterator<Item = &'a T>,
fn extend<I>(&mut self, iterable: I) where
I: IntoIterator<Item = &'a T>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<T, S> Extend<T> for IndexSet<T, S> where
T: Hash + Eq,
S: BuildHasher,
impl<T, S> Extend<T> for IndexSet<T, S> where
T: Hash + Eq,
S: BuildHasher,
sourcefn extend<I>(&mut self, iterable: I) where
I: IntoIterator<Item = T>,
fn extend<I>(&mut self, iterable: I) where
I: IntoIterator<Item = T>,
Extends a collection with the contents of an iterator. Read more
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Extends a collection with exactly one element.
sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Reserves capacity in a collection for the given number of additional elements. Read more
sourceimpl<T, S> FromIterator<T> for IndexSet<T, S> where
T: Hash + Eq,
S: BuildHasher + Default,
impl<T, S> FromIterator<T> for IndexSet<T, S> where
T: Hash + Eq,
S: BuildHasher + Default,
sourcefn from_iter<I>(iterable: I) -> IndexSet<T, S> where
I: IntoIterator<Item = T>,
fn from_iter<I>(iterable: I) -> IndexSet<T, S> where
I: IntoIterator<Item = T>,
Creates a value from an iterator. Read more
sourceimpl<T, S> Index<usize> for IndexSet<T, S>
impl<T, S> Index<usize> for IndexSet<T, S>
Access IndexSet values at indexed positions.
Examples
use indexmap::IndexSet;
let mut set = IndexSet::new();
for word in "Lorem ipsum dolor sit amet".split_whitespace() {
set.insert(word.to_string());
}
assert_eq!(set[0], "Lorem");
assert_eq!(set[1], "ipsum");
set.reverse();
assert_eq!(set[0], "amet");
assert_eq!(set[1], "sit");
set.sort();
assert_eq!(set[0], "Lorem");
assert_eq!(set[1], "amet");use indexmap::IndexSet;
let mut set = IndexSet::new();
set.insert("foo");
println!("{:?}", set[10]); // panics!sourceimpl<'de, T, S, E> IntoDeserializer<'de, E> for IndexSet<T, S> where
T: IntoDeserializer<'de, E> + Eq + Hash,
S: BuildHasher,
E: Error,
impl<'de, T, S, E> IntoDeserializer<'de, E> for IndexSet<T, S> where
T: IntoDeserializer<'de, E> + Eq + Hash,
S: BuildHasher,
E: Error,
type Deserializer = SeqDeserializer<<IndexSet<T, S> as IntoIterator>::IntoIter, E>
type Deserializer = SeqDeserializer<<IndexSet<T, S> as IntoIterator>::IntoIter, E>
The type of the deserializer being converted into.
sourcefn into_deserializer(
self
) -> <IndexSet<T, S> as IntoDeserializer<'de, E>>::Deserializer
fn into_deserializer(
self
) -> <IndexSet<T, S> as IntoDeserializer<'de, E>>::Deserializer
Convert this value into a deserializer.
sourceimpl<'a, T, S> IntoIterator for &'a IndexSet<T, S>
impl<'a, T, S> IntoIterator for &'a IndexSet<T, S>
sourceimpl<T, S> IntoIterator for IndexSet<T, S>
impl<T, S> IntoIterator for IndexSet<T, S>
sourceimpl<T, S1, S2> PartialEq<IndexSet<T, S2>> for IndexSet<T, S1> where
T: Hash + Eq,
S1: BuildHasher,
S2: BuildHasher,
impl<T, S1, S2> PartialEq<IndexSet<T, S2>> for IndexSet<T, S1> where
T: Hash + Eq,
S1: BuildHasher,
S2: BuildHasher,
sourceimpl<T, S> Serialize for IndexSet<T, S> where
T: Serialize + Hash + Eq,
S: BuildHasher,
impl<T, S> Serialize for IndexSet<T, S> where
T: Serialize + Hash + Eq,
S: BuildHasher,
Requires crate feature "serde" or "serde-1"
sourcefn serialize<Se>(
&self,
serializer: Se
) -> Result<<Se as Serializer>::Ok, <Se as Serializer>::Error> where
Se: Serializer,
fn serialize<Se>(
&self,
serializer: Se
) -> Result<<Se as Serializer>::Ok, <Se as Serializer>::Error> where
Se: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl<'_, '_, T, S1, S2> Sub<&'_ IndexSet<T, S2>> for &'_ IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
impl<'_, '_, T, S1, S2> Sub<&'_ IndexSet<T, S2>> for &'_ IndexSet<T, S1> where
T: Eq + Hash + Clone,
S1: BuildHasher + Default,
S2: BuildHasher,
impl<T, S> Eq for IndexSet<T, S> where
T: Eq + Hash,
S: BuildHasher,
Auto Trait Implementations
impl<T, S> RefUnwindSafe for IndexSet<T, S> where
S: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, S> Send for IndexSet<T, S> where
S: Send,
T: Send,
impl<T, S> Sync for IndexSet<T, S> where
S: Sync,
T: Sync,
impl<T, S> Unpin for IndexSet<T, S> where
S: Unpin,
T: Unpin,
impl<T, S> UnwindSafe for IndexSet<T, S> where
S: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>ⓘNotable traits for Box<R, Global>impl<R> Read for Box<R, Global> where
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
R: Read + ?Sized, impl<W> Write for Box<W, Global> where
W: Write + ?Sized, impl<F, A> Future for Box<F, A> where
F: Future + Unpin + ?Sized,
A: Allocator + 'static, type Output = <F as Future>::Output;impl<I, A> Iterator for Box<I, A> where
I: Iterator + ?Sized,
A: Allocator, type Item = <I as Iterator>::Item;
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s. Read more
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s. Read more
impl<A> DynCastExt for A
impl<A> DynCastExt for A
fn dyn_cast<T>(
self
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source> where
A: DynCastExtHelper<T>,
T: ?Sized,
fn dyn_cast<T>(
self
) -> Result<<A as DynCastExtHelper<T>>::Target, <A as DynCastExtHelper<T>>::Source> where
A: DynCastExtHelper<T>,
T: ?Sized,
Use this to cast from one trait object type to another. Read more
fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target where
A: DynCastExtAdvHelper<T, T, Source = <A as DynCastExtAdvHelper<T, T>>::Target>,
T: ?Sized,
fn dyn_upcast<T>(self) -> <A as DynCastExtAdvHelper<T, T>>::Target where
A: DynCastExtAdvHelper<T, T, Source = <A as DynCastExtAdvHelper<T, T>>::Target>,
T: ?Sized,
Use this to upcast a trait to one of its supertraits. Read more
fn dyn_cast_adv<F, T>(
self
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source> where
A: DynCastExtAdvHelper<F, T>,
F: ?Sized,
T: ?Sized,
fn dyn_cast_adv<F, T>(
self
) -> Result<<A as DynCastExtAdvHelper<F, T>>::Target, <A as DynCastExtAdvHelper<F, T>>::Source> where
A: DynCastExtAdvHelper<F, T>,
F: ?Sized,
T: ?Sized,
fn dyn_cast_with_config<C>(
self
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source> where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
fn dyn_cast_with_config<C>(
self
) -> Result<<A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Target, <A as DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>>::Source> where
C: DynCastConfig,
A: DynCastExtAdvHelper<<C as DynCastConfig>::Source, <C as DynCastConfig>::Target>,
Use this to cast from one trait object type to another. With this method the type parameter is a config type that uniquely specifies which cast should be preformed. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key and return true if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourceimpl<T> Serialize for T where
T: Serialize + ?Sized,
impl<T> Serialize for T where
T: Serialize + ?Sized,
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<Ok, Error>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into)Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output; where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output; where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T> where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more