Skip to main content

InitMaybeUninit

Trait InitMaybeUninit 

Source
pub trait InitMaybeUninit<T> {
    // Required method
    fn try_init_with<I, E>(&mut self, init: I) -> Result<&mut T, E>
       where I: Init<T, E>;

    // Provided methods
    fn init_with<I>(&mut self, init: I) -> &mut T
       where I: Init<T> { ... }
    fn init_zeroed(&mut self) -> &mut T
       where T: Zeroable { ... }
}
Expand description

An extension trait that allows safe initialization of MaybeUninit<T> memory.

Required Methods§

Source

fn try_init_with<I, E>(&mut self, init: I) -> Result<&mut T, E>
where I: Init<T, E>,

Try to initialize Self with the given fallible in-place initializer.

Provided Methods§

Source

fn init_with<I>(&mut self, init: I) -> &mut T
where I: Init<T>,

Initialize Self with the given in-place initializer.

Source

fn init_zeroed(&mut self) -> &mut T
where T: Zeroable,

Initialize Self with all-zeroes

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> InitMaybeUninit<T> for MaybeUninit<T>

Source§

fn try_init_with<I, E>(&mut self, init: I) -> Result<&mut T, E>
where I: Init<T, E>,

Implementors§