pub trait IndexedRetain<T> {
// Required method
fn indexed_retain(&mut self, f: impl FnMut(usize, &T) -> bool);
}Expand description
A helper trait to allow calling retain while getting access
to the index of the item in the vec.
Required Methods§
sourcefn indexed_retain(&mut self, f: impl FnMut(usize, &T) -> bool)
fn indexed_retain(&mut self, f: impl FnMut(usize, &T) -> bool)
Retains only the elements specified by the predicate.
In other words, remove all elements e residing at
index i such that f(i, &e) returns false. This method
operates in place, visiting each element exactly once in the
original order, and preserves the order of the retained elements.