I want to copy (not move) a very big value from a box into a vec. The normal way of doing this (dereferencing the box) means the value is copied onto the stack temporarily, which blows it. Here's an example and a Playground link where it can be reproduced.
fn main() {
let big_value = Box::new([0u8; 8 * 1024 * 1024]);
let mut vec = Vec::new();
vec.push(*big_value);
}
Since both the Box and the Vec are on the heap, it should be possible to do a copy without passing through the stack. What's the best solution here?