Skip to main content

ChunkMut

Struct ChunkMut 

Source
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 own

The 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..4

So 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>

Source

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<'a, P: Debug + PackedField> Debug for ChunkMut<'a, P>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<P: PackedField> Drop for ChunkMut<'_, P>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

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> 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.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more