Struct mm0_util::SliceUninit[][src]

pub struct SliceUninit<T>(_);

A way to initialize a Box<[T]> by first constructing the array (giving the length), initializing the elements in some order, and then using the unsafe function assume_init to assert that every element of the array has been initialized and transmute the SliceUninit<T> into a Box<[T]>.

Implementations

impl<T> SliceUninit<T>[src]

#[must_use]
pub fn new(size: usize) -> Self
[src]

Create a new uninitialized slice of length size.

pub fn set(&mut self, i: usize, val: T)[src]

Assign the value val to location i of the slice. Warning: this does not call the destructor for T on the previous value, so this should be used only once per location unless T has no Drop impl.

#[must_use]
pub unsafe fn assume_init(self) -> Box<[T]>
[src]

Finalizes the construction, returning an initialized Box<[T]>.

Safety

This causes undefined behavior if the content is not fully initialized.

Trait Implementations

impl<T: Debug> Debug for SliceUninit<T>[src]

Auto Trait Implementations

impl<T> RefUnwindSafe for SliceUninit<T> where
    T: RefUnwindSafe

impl<T> Send for SliceUninit<T> where
    T: Send

impl<T> Sync for SliceUninit<T> where
    T: Sync

impl<T> Unpin for SliceUninit<T>

impl<T> UnwindSafe for SliceUninit<T> where
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.