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

Initialize a type directly on the stack.

Examples

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

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

let a = Mutex::new(40);

stack_init!(let foo = pin_init!(Foo {
    a,
    b: Bar {
        x: 64,
    },
}));
let foo: Result<Pin<&mut Foo>, Infallible> = foo;