Trait MaybeUninitSlice

Source
pub trait MaybeUninitSlice: Slice<Item = MaybeUninit<Self::InitItem>> {
    type InitItem;

    // Required methods
    unsafe fn assume_init(&self) -> &[Self::InitItem];
    unsafe fn assume_init_mut(&mut self) -> &mut [Self::InitItem];
}
Expand description

Extension for maybe uninitialized slices ([MaybeUninit<_>])

Required Associated Types§

Source

type InitItem

Initialized item i.e.

[MaybeUninit<T>]: MaybeUninitSlice<InitItem = T>

Required Methods§

Source

unsafe fn assume_init(&self) -> &[Self::InitItem]

Assume that all items of self are initialized

§Safety

It is up to the caller to guarantee that all elements of the array are really in an initialized state. Calling this when the content is not yet fully initialized causes immediate undefined behavior. The MaybeUninit's type-level documentation contains more information about this initialization invariant.

See also MaybeUninit::assume_init documentation.

Source

unsafe fn assume_init_mut(&mut self) -> &mut [Self::InitItem]

Assume that all items of self are initialized

§Safety

It is up to the caller to guarantee that all elements of the array are really in an initialized state. Calling this when the content is not yet fully initialized causes immediate undefined behavior. The MaybeUninit's type-level documentation contains more information about this initialization invariant.

See also MaybeUninit::assume_init documentation.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> MaybeUninitSlice for [MaybeUninit<T>]

Source§

type InitItem = T

Source§

unsafe fn assume_init(&self) -> &[Self::InitItem]

Source§

unsafe fn assume_init_mut(&mut self) -> &mut [Self::InitItem]

Implementors§