macro_rules! try_init_on_stack {
    (let $value:tt $(: $ty:ty)? = $($init:tt)*) => { ... };
}
Expand description

Attempts to initialize an owned value directly on the stack using an initializer of Init.

Examples

use owned_pin::try_init_on_stack;
use pinned_init::pin_data;

#[pin_data]
struct X {
    a: [u64; 100],
}

// This value is directly written to the target place,
// instead of being temporarily placed on the stack.
try_init_on_stack!(let x = X {
    a <- [0; 100]
});
assert_eq!(x.unwrap().a, [0; 100]);