pub struct ChunkMut<'a, P: PackedField>(/* private fields */);Expand description
Guards one mutably borrowed chunk of a buffer.
The chunk size against the packing width decides which of two shapes the guard takes:
chunk >= one packed word -> a run of whole words, lent straight from the store
chunk < one packed word -> the chunk's lanes copied into a word of their ownThe first shape edits the store itself. Every edit is therefore already in place, and dropping the guard does nothing.
The second shape edits a copy taken when the guard is built. That copy holds the chunk’s lanes shifted down to start at lane 0. Dropping the guard writes them back to the lanes they came from, and nothing else.
WIDTH = 4, chunks of 2 elements, chunk 1 of word 0
word before [ a b c d ]
detached [ c d . . ] lanes 2..4 copied down to lanes 0..2
after edits [ y z . . ]
word on drop [ a b y z ] lanes 0..2 written back to lanes 2..4So an edit to a sub-word chunk reaches the buffer when the guard drops, and not before. Neighbouring chunks sharing the word keep their elements, since the merge skips their lanes.
Only one such guard can exist at a time, since it borrows the buffer mutably. Two live guards over chunks of one word would each merge a stale copy. The later merge would then undo the earlier one.
Implementations§
Source§impl<'a, P: PackedField> ChunkMut<'a, P>
impl<'a, P: PackedField> ChunkMut<'a, P>
Sourcepub const fn chunk(&mut self) -> FieldSliceMut<'_, P>
pub const fn chunk(&mut self) -> FieldSliceMut<'_, P>
Lends the chunk out as a mutable view, its first element at index 0.
A chunk of whole words is a view straight onto the store, so edits land at once. A narrower chunk is a view onto the detached copy, so edits land when this guard drops.
Trait Implementations§
Source§impl<P: PackedField> Drop for ChunkMut<'_, P>
impl<P: PackedField> Drop for ChunkMut<'_, P>
Auto Trait Implementations§
impl<'a, P> !UnwindSafe for ChunkMut<'a, P>
impl<'a, P> Freeze for ChunkMut<'a, P>where
P: Freeze,
impl<'a, P> RefUnwindSafe for ChunkMut<'a, P>where
P: RefUnwindSafe,
impl<'a, P> Send for ChunkMut<'a, P>
impl<'a, P> Sync for ChunkMut<'a, P>
impl<'a, P> Unpin for ChunkMut<'a, P>where
P: Unpin,
impl<'a, P> UnsafeUnpin for ChunkMut<'a, P>where
P: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more