Struct ExtractIf

#[must_use = "iterators are lazy and do nothing unless consumed; use `retain_mut` or `extract_if().for_each(drop)` to remove and discard elements"]
pub struct ExtractIf<'a, T, F, A: Allocator = Global> { pub(in ::vec::extract_if) vec: &'a mut Vec<T, A>, pub(in ::vec::extract_if) idx: usize, pub(in ::vec::extract_if) end: usize, pub(in ::vec::extract_if) del: usize, pub(in ::vec::extract_if) old_len: usize, pub(in ::vec::extract_if) pred: F }

An iterator which uses a closure to determine if an element should be removed.

This struct is created by Vec::extract_if. See its documentation for more.

Example

let mut v = vec![0, 1, 2];
let iter: std::vec::ExtractIf<'_, _, _> = v.extract_if(.., |x| *x % 2 == 0);

Fields

vec: &'a mut Vec<T, A>
idx: usize

The index of the item that will be inspected by the next call to next.

end: usize

Elements at and beyond this point will be retained. Must be equal or smaller than old_len.

del: usize

The number of items that have been drained (removed) thus far.

old_len: usize

The original length of vec prior to draining.

pred: F

The filter test predicate.

Implementations

impl<'a, T, F, A: Allocator> ExtractIf<'a, T, F, A>

fn new<R: RangeBounds<usize>>(vec: &'a mut Vec<T, A>, pred: F, range: R) -> Self
fn allocator(&self) -> &A

Returns a reference to the underlying allocator.

Trait Implementations

impl<T, F, A> Debug for ExtractIf<'_, T, F, A> where T: Debug, A: Allocator,

fn fmt(&self, f: &mut Formatter<'_>) -> Result

impl<T, F, A: Allocator> Drop for ExtractIf<'_, T, F, A>

fn drop(&mut self)

impl<T, F, A: Allocator> Iterator for ExtractIf<'_, T, F, A> where F: FnMut(&mut T) -> bool,

type Item = T;
fn next(&mut self) -> Option<T>
fn size_hint(&self) -> (usize, Option<usize>)

Auto Trait Implementations

impl<'a, T, F, A = Global> !UnwindSafe for ExtractIf<'a, T, F, A>

impl<'a, T, F, A> Freeze for ExtractIf<'a, T, F, A> where &'a mut Vec<T, A>: Freeze, F: Freeze,

impl<'a, T, F, A> RefUnwindSafe for ExtractIf<'a, T, F, A> where &'a mut Vec<T, A>: RefUnwindSafe, F: RefUnwindSafe,

impl<'a, T, F, A> Send for ExtractIf<'a, T, F, A> where &'a mut Vec<T, A>: Send, F: Send,

impl<'a, T, F, A> Sync for ExtractIf<'a, T, F, A> where &'a mut Vec<T, A>: Sync, F: Sync,

impl<'a, T, F, A> Unpin for ExtractIf<'a, T, F, A> where &'a mut Vec<T, A>: Unpin, F: Unpin,

impl<'a, T, F, A> UnsafeUnpin for ExtractIf<'a, T, F, A> where &'a mut Vec<T, A>: UnsafeUnpin, F: UnsafeUnpin,

Blanket Implementations

impl<I> IntoIterator for ExtractIf<'a, T, F, A> where I: Iterator,

type Item = <I as Iterator>::Item;
type IntoIter = I;
fn into_iter(self) -> I

impl<T> Any for ExtractIf<'a, T, F, A> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for ExtractIf<'a, T, F, A> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for ExtractIf<'a, T, F, A> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> From<T> for ExtractIf<'a, T, F, A>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for ExtractIf<'a, T, F, A> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for ExtractIf<'a, T, F, A>

impl<T, U> Into<U> for ExtractIf<'a, T, F, A> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for ExtractIf<'a, T, F, A> where U: Into<T>,

type Error = Infallible;
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

impl<T, U> TryInto<U> for ExtractIf<'a, T, F, A> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>