ownership
Rust Reinitialize a moved binding
A move does not erase the binding name. A mutable binding can be assigned a new value after a move, restoring its availability. The destination still owns the old value. Expected output (not executed): Apples / Bread Why: cart is initialized with a different String after the move. Common mistake: Assuming reinitialization restores access to the original value or that mut prevents a move.
Formal Syntax & Structure
rust syntaxrust
let mut source = value; let target = source; source = new_value;Working Example
Example Snippetrust
fn main() { let mut cart = String::from("Apples"); let order = cart; cart = String::from("Bread"); println!("{order} / {cart}");}