doc.rust-lang.org
pub const fn needs_drop<T>() -> bool
Returns true if dropping values of type T matters.
function
core
Stable since 1.21.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn min_align_of_val<T>(val: &T) -> usize
Returns the ABI-required minimum alignment of the type of the value that val points to in bytes.
function
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub fn min_align_of<T>() -> usize
Returns the ABI-required minimum alignment of a type in bytes.
function
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn zeroed() -> MaybeUninit<T>
Creates a new MaybeUninit<T> in an uninitialized state, with the memory being filled with 0 bytes. It depends on T whether that already makes for proper initialization. For example, MaybeUninit<usize>::zeroed() is initialized, but MaybeUninit<&'static i32>::zeroed() is not because references must not be null.
associated_function
core
Stable since 1.36.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn write(&mut self, val: T) -> &mut T
Sets the value of the MaybeUninit<T>.
method
core
Stable since 1.55.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn uninit() -> MaybeUninit<T>
Creates a new MaybeUninit<T> in an uninitialized state.
associated_function
core
Stable since 1.36.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn new(val: T) -> MaybeUninit<T>
Creates a new MaybeUninit<T> initialized with the given value. It is safe to call assume_init on the return value of this function.
associated_function
core
Stable since 1.36.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn assume_init_ref(&self) -> &T
Gets a shared reference to the contained value.
method
core
Stable since 1.55.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn assume_init_read(&self) -> T
Reads the value from the MaybeUninit<T> container. The resulting T is subject to the usual drop handling.
method
core
Stable since 1.60.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn assume_init_mut(&mut self) -> &mut T
Gets a mutable (unique) reference to the contained value.
method
core
Stable since 1.55.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn assume_init_drop(&mut self)
Drops the contained value in place.
method
core
Stable since 1.60.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn assume_init(self) -> T
Extracts the value from the MaybeUninit<T> container. This is a great way to ensure that the data will get dropped, because the resulting T is subject to the usual drop handling.
method
core
Stable since 1.36.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn as_ptr(&self) -> *const T
Gets a pointer to the contained value. Reading from this pointer or turning it into a reference is undefined behavior unless the MaybeUninit<T> is initialized. Writing to memory that this pointer (non-transitively) points to is undefined behavior (except inside an UnsafeCell<T>).
method
core
Stable since 1.36.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn as_mut_ptr(&mut self) -> *mut T
Gets a mutable pointer to the contained value. Reading from this pointer or turning it into a reference is undefined behavior unless the MaybeUninit<T> is initialized.
method
core
Stable since 1.36.0
Version 1.100.0-nightly
doc.rust-lang.org
pub union MaybeUninit<T>
A wrapper type to construct uninitialized instances of T.
union
core
Stable since 1.36.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn take(slot: &mut ManuallyDrop<T>) -> T
Takes the value from the ManuallyDrop<T> container out.
associated_function
core
Stable since 1.42.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn new(value: T) -> ManuallyDrop<T>
Wrap a value to be manually dropped.
associated_function
core
Stable since 1.20.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn into_inner(slot: ManuallyDrop<T>) -> T
Extracts the value from the ManuallyDrop container.
associated_function
core
Stable since 1.20.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn drop(slot: &mut ManuallyDrop<T>)
Manually drops the contained value.
associated_function
core
Stable since 1.20.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct ManuallyDrop<T>
A wrapper to inhibit the compiler from automatically calling T’s destructor. This wrapper is 0-cost.
struct
core
Stable since 1.20.0
Version 1.100.0-nightly