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

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

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

pin_data! {
    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;