Trait select_indices::SelectIndicesMut
source · [−]pub trait SelectIndicesMut<'a> {
unsafe fn select_with_iter_mut_unchecked<Indices>(
&'a mut self,
indices: Indices
) -> SelectIndicesMutIter<'_, Self, Indices::IntoIter, (), Unindexed>
where
Indices: IntoIterator,
Indices::Item: Copy,
Self: IndexMut<Indices::Item>,
{ ... }
unsafe fn select_indices_mut_unchecked<Idx>(
&'a mut self,
indices: &'a [Idx]
) -> SelectIndicesMutIter<'_, Self, Copied<Iter<'a, Idx>>, (), Unindexed>
where
Self: IndexMut<Idx>,
Idx: Copy,
{ ... }
fn select_indices_mut<Idx>(
&'a mut self,
indices: &'a [Idx]
) -> SelectIndicesMutIter<'_, Self, Copied<Iter<'a, Idx>>, (), Unindexed>
where
Self: OneToOne<Idx>,
Idx: Sized + Eq + Hash + Copy,
{ ... }
fn select_with_iter_mut<Indices>(
&'a mut self,
indices: Indices
) -> SelectIndicesMutIter<'_, Self, Indices::IntoIter, HashSet<usize>, Unindexed>
where
Indices: IntoIterator,
Indices::Item: Copy + Hash + Eq,
Self: OneToOne<Indices::Item>,
{ ... }
}
Expand description
Selectively iterate through a mutable collection with a list of indices or an index iterator.
Provided methods
unsafe fn select_with_iter_mut_unchecked<Indices>(
&'a mut self,
indices: Indices
) -> SelectIndicesMutIter<'_, Self, Indices::IntoIter, (), Unindexed> where
Indices: IntoIterator,
Indices::Item: Copy,
Self: IndexMut<Indices::Item>,
unsafe fn select_with_iter_mut_unchecked<Indices>(
&'a mut self,
indices: Indices
) -> SelectIndicesMutIter<'_, Self, Indices::IntoIter, (), Unindexed> where
Indices: IntoIterator,
Indices::Item: Copy,
Self: IndexMut<Indices::Item>,
Iterate through a collection with an iterator that produces indices, without checking for duplicate indices.
Performance
This method will not check the indices before or during iteration, which makes it faster than the safe form.
Safety
This is safe if the indices produced are unique and do not
violate OneToOne
guarantees with the given collection.
Otherwise, undefined behavior will occur and XOR mutability
will be violated.
Iterate through a collection with a slice of indices, without checking if the indices are unique.
Performance
This method will not check the indices before or during iteration, which makes it faster than the safe form.
Safety
This is safe if the given indices are unique and do not
violate OneToOne
guarantees with the given collection.
Otherwise, undefined behavior will occur and XOR mutability
will be violated.
Iterate through a collection with a slice of indices.
This method requires that the collection given implements OneToOne
. For the
unsafe form without this requirement, see
select_indices_mut_unchecked
.
Performance
This method checks that all indices are unique before returning
the iterator. Because of that, this method is slightly slower
than select_with_iter_mut
,
but the resulting iterator is slightly faster, because it does
not need to check for duplicate indices at every index. Overall,
this method is slightly faster.
Iterate through a collection given an iterator that produces indices.
This method requires that the collection given implements OneToOne
. For the
unsafe form without this requirement, see
select_with_iter_mut_unchecked
.
Performance
The iterator produced by this method maintains a HashSet of previously returned
references to ensure that XOR mutability is not violated. If your indices are
contained within a slice, consider using
select_indices_mut
for a faster and more efficient iterator.