Macro pin_init::init_stack [−][src]
macro_rules! init_stack { ($var:ident = $init:expr) => { ... }; }
Expand description
Create and pin-initialize a new variable on the stack.
init_stack!(p = NeedPin::new); // Now `p` is a `Result<Pin<&mut NeedPin>, Infallible>`.
Can be used together with init_pin!
:
#[pin_init] struct ManyPin { #[pin] a: NeedPin, b: usize, } init_stack!(p = init_pin!(ManyPin { a: NeedPin::new, b: 0, }));
The initializers should not panic, and should use Err
to report failures.
If the initializer fails, because we cannot tell whether the value is
initialized or not (or even just partially initialized), drop guarantee cannot
be kept, this macro will abort the process.