Struct sealingslice::SealingSlice
source · pub struct SealingSlice<'s, T: 's> { /* private fields */ }
Expand description
A slice that can seal parts of itself off from mutability, and hand out the sealed parts as immutable references.
The slice grows immutable from start to end in a contiguous way, is initially mutable as a whole. The seal is moved forward using the .seal(n) method. The sealed and unsealed parts can be accessed with the .sealed() and .mutable() methods, respectively.
Implementations§
source§impl<'s, T> SealingSlice<'s, T>
impl<'s, T> SealingSlice<'s, T>
sourcepub fn new(slice: &'s mut [T]) -> Self
pub fn new(slice: &'s mut [T]) -> Self
Create a new SealingSlice
. The slice is initially fully mutable.
sourcepub fn seal(&mut self, n: usize)
pub fn seal(&mut self, n: usize)
Seal off n
more items in the slice.
Like out-of-bounds slice access, this panics if n is less than .mutable().len()
– thus
ensuring that .sealed()
and .mutable()
will not.