VecGrowScanItem

Struct VecGrowScanItem 

Source
pub struct VecGrowScanItem<'s, 'a, T: 'a> { /* private fields */ }
Expand description

Reference wrapper that enables item insertion and removal for VecGrowScan.

Implementations§

Source§

impl<'s, 'a, T: 'a> VecGrowScanItem<'s, 'a, T>

Source

pub fn remove(self) -> T

Removes and returns this item from the vector.

Source

pub fn replace(self, value: T) -> T

Replaces this item with a new value, returns the old value.

This is equivalent to assigning a new value or calling mem::replace on the mutable reference obtained by using DerefMut, but can avoid an intermediate move within the vector’s buffer.

Source

pub fn replace_with_many(self, values: impl IntoIterator<Item = T>) -> T

Replace the current item with a sequence of items. Returns the replaced item.

Source

pub fn replace_with(self, f: impl FnOnce(T) -> T)

Like replace, but compute the replacement value with ownership of the removed item.

Source

pub fn replace_with_many_with<F, I>(self, f: F)
where F: FnOnce(T) -> I, I: IntoIterator<Item = T>,

Like replace_with_many, but compute the replacement sequence with ownership of the removed item.

Source

pub fn insert_before(&mut self, value: T)

Insert an item before the current item.

Source

pub fn insert_many_before(&mut self, values: impl IntoIterator<Item = T>)

Insert a sequence of items before the current item.

Equivalent to repeatedly calling insert_before, except that reallocations will be minimized with iterator size hints.

Source

pub fn insert_after(self, value: T)

Insert an item after the current item. Inserted items are not returned during iteration.

Note that this consumes the VecGrowScanItem, as it is necessary to commit that the current item will not be removed. If you need to insert multiple elements, you can either use insert_many_after, or use VecGrowScan::insert after you drop this VecGrowScanItem.

Source

pub fn insert_many_after(self, values: impl IntoIterator<Item = T>)

Insert a sequence of items after the current item. Inserted items are not returned during iteration.

Note that this consumes the VecGrowScanItem, as it is necessary to commit that the current item will not be removed. If you need to insert more elements, you can use VecGrowScan::insert (or insert_many) after you drop this VecGrowScanItem.

Source

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

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, and some of the contents may be kept out-of-place in a VecDeque. Thus the content is returned as four slices. The first three slices, in order, contain all elements already visited, while the fourth slice contains the remaining elements starting with this element.

This method is also present on the VecGrowScan borrowed by this reference wrapper, allowing access without an active VecGrowScanItem.

Source

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

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, and some of the contents may be kept out-of-place in a VecDeque. Thus the content is returned as four slices. The first three slices, in order, contain all elements already visited, while the fourth slice contains the remaining elements starting with this element.

This method is also present on the VecGrowScan borrowed by this reference wrapper, allowing access without an active VecGrowScanItem.

Trait Implementations§

Source§

impl<'s, 'a, T: 'a> Deref for VecGrowScanItem<'s, 'a, T>

Source§

type Target = T

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'s, 'a, T: 'a> DerefMut for VecGrowScanItem<'s, 'a, T>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'s, 'a, T: 'a> Drop for VecGrowScanItem<'s, 'a, T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'s, 'a, T> Freeze for VecGrowScanItem<'s, 'a, T>

§

impl<'s, 'a, T> RefUnwindSafe for VecGrowScanItem<'s, 'a, T>
where T: RefUnwindSafe,

§

impl<'s, 'a, T> !Send for VecGrowScanItem<'s, 'a, T>

§

impl<'s, 'a, T> !Sync for VecGrowScanItem<'s, 'a, T>

§

impl<'s, 'a, T> Unpin for VecGrowScanItem<'s, 'a, T>

§

impl<'s, 'a, T> !UnwindSafe for VecGrowScanItem<'s, 'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.