jex on Nostr: simple example showcasing stack vs heap behavior let w = 5; let x = w; // two copies ...
simple example showcasing stack vs heap behavior
let w = 5;
let x = w; // two copies of value w now on the stack
let y = Box::new(w); // copy value w on the heap (y points to it from stack)
let z = y // ownership change. y goes out of scope and now z points to that value on the heap.
let w = 5;
let x = w; // two copies of value w now on the stack
let y = Box::new(w); // copy value w on the heap (y points to it from stack)
let z = y // ownership change. y goes out of scope and now z points to that value on the heap.