macro_rules! stack_pin_init {
    (let $var:ident $(: $t:ty)? = $val:expr) => { ... };
}
Expand description

Initialize and pin a type directly on the stack.

§Examples

#[pin_data]
struct Foo {
    #[pin]
    a: Mutex<usize>,
    b: Bar,
}

#[pin_data]
struct Bar {
    x: u32,
}

stack_pin_init!(let foo = pin_init!(Foo {
    a <- new_mutex!(42),
    b: Bar {
        x: 64,
    },
}));
let foo: Pin<&mut Foo> = foo;
pr_info!("a: {}", &*foo.a.lock());

§Syntax

A normal let binding with optional type annotation. The expression is expected to implement PinInit/Init with the error type Infallible. If you want to use a different error type, then use stack_try_pin_init!.