Macro inline_dyn::inline_dyn_box[][src]

macro_rules! inline_dyn_box {
    ($trait:path $(: $($_arg:ident),*)?; $e:expr) => { ... };
}
This is supported on crate feature alloc only.

Construct a new InlineDyn for the specified trait containing the given value if the value can fit in the internal storage, or else box the value and store that.

Examples

use core::fmt::Debug;
use inline_dyn::{fmt::InlineDynDebug, inline_dyn_box};

#[derive(Debug)]
struct LargerThanBox([usize; 5]);

let val: InlineDynDebug = inline_dyn_box![Debug; LargerThanBox([1, 2, 3, 4, 5])];
assert_eq!(format!("{:?}", val), "LargerThanBox([1, 2, 3, 4, 5])");