4 ms·
There is a difference between a variable and a value. The value is definitely read only or you would need a mut modifier. The variable binding changes in a simi
by eddd-ddde 3y ago
There is a difference between a variable and a value. The value is definitely read only or you would need a mut modifier. The variable binding changes in a similar way to shadowing it with a new 'let' on the same name.
- fauigerzigerk 3y agoThis would imply that the variable can get its value back once the new binding is out of scope. But that is not the case as this doesn't compile: let s1 = String::from("abc"); { let s2 = s1; } println!("{}", s1); //borrow of moved value: `s1` But I do understand what you're getting at. In a sense, a move is not a runtime concept at all. The compiler simply considers the variable as no longer readable unless and until a new value is actually written to it.