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]
#[must_use]
pub fn new(size: usize) -> SelfCreate 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]
#[must_use]
pub unsafe fn assume_init(self) -> Box<[T]>Finalizes the construction, returning an initialized Box<[T]>
.
Safety
This causes undefined behavior if the content is not fully initialized.
Trait Implementations
Auto Trait Implementations
impl<T> RefUnwindSafe for SliceUninit<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for SliceUninit<T> where
T: Send,
T: Send,
impl<T> Sync for SliceUninit<T> where
T: Sync,
T: Sync,
impl<T> Unpin for SliceUninit<T>
impl<T> UnwindSafe for SliceUninit<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[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]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,