Skip to main content

InPlaceInit

Trait InPlaceInit 

Source
pub trait InPlaceInit<T>: Sized {
    // Required methods
    fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
       where E: From<AllocError>;
    fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
       where E: From<AllocError>;

    // Provided methods
    fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError> { ... }
    fn init(init: impl Init<T>) -> Result<Self, AllocError> { ... }
}
Expand description

Smart pointer that can initialize memory in-place.

Required Methods§

Source

fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
where E: From<AllocError>,

Use the given pin-initializer to pin-initialize a T inside of a new smart pointer of this type.

If T: !Unpin it will not be able to move afterwards.

Source

fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
where E: From<AllocError>,

Use the given initializer to in-place initialize a T.

Provided Methods§

Source

fn pin_init(init: impl PinInit<T>) -> Result<Pin<Self>, AllocError>

Use the given pin-initializer to pin-initialize a T inside of a new smart pointer of this type.

If T: !Unpin it will not be able to move afterwards.

Source

fn init(init: impl Init<T>) -> Result<Self, AllocError>

Use the given initializer to in-place initialize a T.

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> InPlaceInit<T> for Box<T>

Source§

fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
where E: From<AllocError>,

Source§

fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
where E: From<AllocError>,

Source§

impl<T> InPlaceInit<T> for Arc<T>

Source§

fn try_pin_init<E>(init: impl PinInit<T, E>) -> Result<Pin<Self>, E>
where E: From<AllocError>,

Source§

fn try_init<E>(init: impl Init<T, E>) -> Result<Self, E>
where E: From<AllocError>,

Implementors§