Skip to main content

Wrapper

Trait Wrapper 

Source
pub trait Wrapper<T> {
    // Required method
    fn pin_init<E>(value_init: impl PinInit<T, E>) -> impl PinInit<Self, E>;
}
Expand description

This trait allows creating an instance of Self which contains exactly one structurally pinned value.

This is useful when using wrapper structs like UnsafeCell or with new-type structs.

§Examples


#[pin_data]
struct Foo {}

#[pin_data]
struct Bar {
    #[pin]
    content: UnsafeCell<Foo>
};

let foo_initializer = pin_init!(Foo{});
let initializer = pin_init!(Bar {
    content <- UnsafeCell::pin_init(foo_initializer)
});

Required Methods§

Source

fn pin_init<E>(value_init: impl PinInit<T, E>) -> impl PinInit<Self, E>

Creates an pin-initializer for a Self containing T from the value_init initializer.

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> Wrapper<T> for UnsafeCell<T>

Source§

fn pin_init<E>(value_init: impl PinInit<T, E>) -> impl PinInit<Self, E>

Source§

impl<T> Wrapper<T> for MaybeUninit<T>

Source§

fn pin_init<E>(value_init: impl PinInit<T, E>) -> impl PinInit<Self, E>

Implementors§