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

Initialize a type on the stack. It will be pinned:

struct Foo {
    a: usize,
    b: Bar,
}

struct Bar {
    x: u32,
}

let a = 42;

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