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>
impl<'s, 'a, T: 'a> VecGrowScanItem<'s, 'a, T>
Sourcepub fn replace(self, value: T) -> T
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.
Sourcepub fn replace_with_many(self, values: impl IntoIterator<Item = T>) -> T
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.
Sourcepub fn replace_with(self, f: impl FnOnce(T) -> T)
pub fn replace_with(self, f: impl FnOnce(T) -> T)
Like replace, but compute the replacement value with
ownership of the removed item.
Sourcepub fn replace_with_many_with<F, I>(self, f: F)where
F: FnOnce(T) -> I,
I: IntoIterator<Item = T>,
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.
Sourcepub fn insert_before(&mut self, value: T)
pub fn insert_before(&mut self, value: T)
Insert an item before the current item.
Sourcepub fn insert_many_before(&mut self, values: impl IntoIterator<Item = T>)
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.
Sourcepub fn insert_after(self, value: T)
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.
Sourcepub fn insert_many_after(self, values: impl IntoIterator<Item = T>)
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.
Sourcepub fn slices(&self) -> (&[T], &[T], &[T], &[T])
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.
Sourcepub fn slices_mut(&mut self) -> (&mut [T], &mut [T], &mut [T], &mut [T])
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.