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 struct
s like UnsafeCell
or with new-type struct
s.
§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§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.