The Rust Box::new(X)
method first creates X
on the stack, then allocates memory
and copies X
from the stack to the heap. That is very wasteful if X
is large.
- Github issue: rust-lang/rust#49733
- Workaround crate: https://github.com/kvark/copyless
Simple macro that abuses vec!
to do more or less the same as the copyless
crate:
macro_rules! boxed {