Moved Strings in Rust
fn main() { let s1: String = String::from("Rust"); let s2: String = s1; }
- The heap data from
s1
is reused fors2
. - When
s1
goes out of scope, nothing happens (it has been moved from).
Before move to s2
:
After move to s2
: