Skip to main content

SegmentsMut

Struct SegmentsMut 

Source
pub struct SegmentsMut<'a, T, const N: usize> { /* private fields */ }
Expand description

A guard over several disjoint typed sub-ranges of one account, returned by AccountView::split_segments_mut.

It holds a single exclusive byte borrow of the account plus N registry leases (one per range) that proved pairwise disjointness at construction and release on drop. Because the ranges are disjoint and all sit inside the one borrow, all_mut can hand out N independent &mut T simultaneously. This is the generalized split_at_mut for account fields that ordinary segment_mut cannot express.

Implementations§

Source§

impl<'a, T: Pod, const N: usize> SegmentsMut<'a, T, N>

Source

pub const fn len(&self) -> usize

Number of disjoint segments held.

Source

pub const fn is_empty(&self) -> bool

Always false (a split with N == 0 is not constructed).

Source

pub fn get_mut(&mut self, i: usize) -> Option<&mut T>

Mutably access one segment by batch index.

Source

pub fn all_mut(&mut self) -> [&mut T; N]

Borrow all segments mutably at once as [&mut T; N].

Sound because the offsets are pairwise disjoint (proven by the registry at construction) and every range lies inside the single exclusive byte borrow, so the references never alias.

Trait Implementations§

Source§

impl<'a, T, const N: usize> Debug for SegmentsMut<'a, T, N>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, T, const N: usize> !Send for SegmentsMut<'a, T, N>

§

impl<'a, T, const N: usize> !Sync for SegmentsMut<'a, T, N>

§

impl<'a, T, const N: usize> !UnwindSafe for SegmentsMut<'a, T, N>

§

impl<'a, T, const N: usize> Freeze for SegmentsMut<'a, T, N>
where [usize; N]: Freeze, [SegmentLease<'a>; N]: Freeze, PhantomData<fn() -> T>: Freeze,

§

impl<'a, T, const N: usize> RefUnwindSafe for SegmentsMut<'a, T, N>

§

impl<'a, T, const N: usize> Unpin for SegmentsMut<'a, T, N>
where [usize; N]: Unpin, [SegmentLease<'a>; N]: Unpin, PhantomData<fn() -> T>: Unpin,

§

impl<'a, T, const N: usize> UnsafeUnpin for SegmentsMut<'a, T, N>

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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.