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§

source

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.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> IndexedRetain<T> for Vec<T>

source§

fn indexed_retain(&mut self, f: impl FnMut(usize, &T) -> bool)

Implementors§