Mind the following code:
enum Store {
Place { val: Vec<u8> },
}
fn subst(val: Vec<u8>, store: &mut Store) {
*store = Store::Place { val }
}
If I understand correctly, here, subst
will move val
to inside store
, which causes it to be copied. Is there any way to do so without copying the whole vector? By "copy" I mean a memory copy. My understanding is that, when a value is moved (such as vec
when calling subst(vec, ...)
, it requires a full copy to erase the data from the parent function's stack and allocate on the called function's stack.