[][src]Struct vec_mut_scan::VecMutScan

pub struct VecMutScan<'a, T: 'a> { /* fields omitted */ }

Forward scan over a vector with mutation and item removal.

Provides an iterator like interface over a vector which allows mutation and removal of items.

If you need to also add new elements, see VecGrowScan.

Items are kept in order and every item is moved at most once, even when items are removed. Dropping the VecMutScan mid-iteration keeps remaining items in the vector.

This does not implement the iterator trait, as the returned items borrow from this (i.e. this is a streaming iterator).

The next method returns VecMutScanItem values, which auto dereference to the vector's item type but also provide a remove and replace method.

Implementations

impl<'a, T: 'a> VecMutScan<'a, T>[src]

pub fn new(vec: &mut Vec<T>) -> VecMutScan<'_, T>[src]

Begin a scan over a vector with mutation and item removal.

pub fn next<'s>(&'s mut self) -> Option<VecMutScanItem<'s, 'a, T>>[src]

Advance to the next item of the vector.

This returns a reference wrapper that enables item removal (see VecMutScanItem).

pub fn slices(&self) -> (&[T], &[T])[src]

Access the whole vector.

This provides access to the whole vector at any point during the scan. In general while scanning, the vector content is not contiguous, thus it is returned as two slices, a prefix and a suffix. The prefix contains all elements already visited while the suffix contains the remaining elements starting with the element that will be returned by the following next call.

This method is also present on the VecMutScanItem reference wrapper returned by next, allowing access while that wrapper borrows this VecMutScan.

pub fn slices_mut(&mut self) -> (&mut [T], &mut [T])[src]

Access and mutate the whole vector.

This provides mutable access to the whole vector at any point during the scan. In general while scanning, the vector content is not contiguous, thus it is returned as two slices, a prefix and a suffix. The prefix contains all elements already visited while the suffix contains the remaining elements starting with the element that will be returned by the following next call.

This method is also present on the VecMutScanItem reference wrapper returned by next, allowing access while that wrapper borrows this VecMutScan.

Trait Implementations

impl<'a, T: 'a> Drop for VecMutScan<'a, T>[src]

Auto Trait Implementations

impl<'a, T> RefUnwindSafe for VecMutScan<'a, T> where
    T: RefUnwindSafe
[src]

impl<'a, T> !Send for VecMutScan<'a, T>[src]

impl<'a, T> !Sync for VecMutScan<'a, T>[src]

impl<'a, T> Unpin for VecMutScan<'a, T>[src]

impl<'a, T> !UnwindSafe for VecMutScan<'a, T>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.