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: CMutex<usize>,
    b: Bar,
}

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

stack_pin_init!(let foo = pin_init!(Foo {
    a <- CMutex::new(42),
    b: Bar {
        x: 64,
    },
}));
let foo: Pin<&mut Foo> = foo;
println!("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!.