Skip to main content

Guard

Struct Guard 

Source
pub struct Guard<'a, T, const N: usize, const REVERSE: bool = false, P = ()> { /* private fields */ }
Expand description

Exclusive initialization of one caller-owned array.

Implementations§

Source§

impl<'a, T, const N: usize, const REVERSE: bool> Guard<'a, T, N, REVERSE>

Source

pub fn new(entries: &'a mut MaybeUninit<[T; N]>) -> Self

Initializes in array order; REVERSE selects reverse release of an abandoned prefix.

Source

pub fn try_map<'source, U, V, E>( entries: &'a mut [MaybeUninit<U>; N], source: &'source Prefix<'_, '_, V, N>, map: impl FnMut(&'source V) -> Result<Option<T>, E>, ) -> Result<Self, (Self, E)>

Maps an admitted source into at most one value per initialized position. On failure, the caller retains the initialized prefix for rollback.

Source

pub fn next( self, ) -> ControlFlow<Guard<'a, T, N, REVERSE, Full>, Guard<'a, T, N, REVERSE, Vacant>>

Completes the array or transfers initialization to its next position.

Source§

impl<T, const N: usize, const REVERSE: bool> Guard<'_, T, N, REVERSE, Full>

Source

pub fn into_array(self) -> [T; N]

Source

pub fn map_with<U, V>( self, values: [U; N], map: impl FnMut(T, U) -> V, ) -> [V; N]

Consumes matching initialized positions once, without moving the full source array.

Source§

impl<'a, T, const N: usize, const REVERSE: bool> Guard<'a, T, N, REVERSE, Vacant>

Source

pub fn get<'b, U>(&self, values: &'b [U; N]) -> &'b U

Selects the same bounded position in another complete array.

Source

pub fn get_mut<'b, U>(&self, values: &'b mut [U; N]) -> &'b mut U

Retains exclusive access to the same bounded position.

Source

pub fn zip<'b, 'c, U>( &'b self, values: &'c [U; N], ) -> Zip<Iter<'b, T>, Iter<'c, U>> ⓘ

Pairs the initialized prefix with the same positions in a complete array.

Source

pub fn insert(self, value: T) -> Guard<'a, T, N, REVERSE>

Initializes this position once and returns the extended prefix.

Source§

impl<'a, T, const N: usize, const REVERSE: bool, P> Guard<'a, T, N, REVERSE, P>

Source

pub fn as_slice(&self) -> &[T]

Trait Implementations§

Source§

impl<T, const N: usize, const REVERSE: bool, P> Drop for Guard<'_, T, N, REVERSE, 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
Source§

impl<'a, T, const N: usize, const REVERSE: bool, P> IntoIterator for Guard<'a, T, N, REVERSE, P>

Source§

type Item = T

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<'a, T, REVERSE>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'a, T, const N: usize, const REVERSE: bool = false, P = ()> !UnwindSafe for Guard<'a, T, N, REVERSE, P>

§

impl<'a, T, const N: usize, const REVERSE: bool, P> Freeze for Guard<'a, T, N, REVERSE, P>
where &'a mut [MaybeUninit<T>; N]: Freeze, PhantomData<P>: Freeze,

§

impl<'a, T, const N: usize, const REVERSE: bool, P> RefUnwindSafe for Guard<'a, T, N, REVERSE, P>

§

impl<'a, T, const N: usize, const REVERSE: bool, P> Send for Guard<'a, T, N, REVERSE, P>
where &'a mut [MaybeUninit<T>; N]: Send, PhantomData<P>: Send,

§

impl<'a, T, const N: usize, const REVERSE: bool, P> Sync for Guard<'a, T, N, REVERSE, P>
where &'a mut [MaybeUninit<T>; N]: Sync, PhantomData<P>: Sync,

§

impl<'a, T, const N: usize, const REVERSE: bool, P> Unpin for Guard<'a, T, N, REVERSE, P>
where &'a mut [MaybeUninit<T>; N]: Unpin, PhantomData<P>: Unpin,

§

impl<'a, T, const N: usize, const REVERSE: bool, P> UnsafeUnpin for Guard<'a, T, N, REVERSE, P>
where &'a mut [MaybeUninit<T>; N]: UnsafeUnpin, PhantomData<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> Convert<T> for T

Source§

fn into(self) -> T

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.