[][src]Macro no_alloc::boxed_s

macro_rules! boxed_s {
    ($val:expr) => { ... };
}

Box a value on the stack.

This macro exists as DST coercion currently requires a nightly compiler. It will be deprecated once this hits stable.

For more info, see #27732.

Note that just like BoxS::new the space and alignment demands for the box are evaluated at compile time. Attempting to use this macro to construct a boxed value with invalid backing storage will result in a compilation failure.

Examples

Boxing a value on the stack, coercing to a DST:

use core::any::Any;
use no_alloc::{boxed_s, BoxS};

let boxed: BoxS<dyn Any, [usize; 1]> = boxed_s!(0_isize);