Rust 中移动的字符串
fn main() { let s1: String = String::from("Rust"); let s2: String = s1; }
s1
中的堆数据会被s2
重复使用。- 当
s1
离开作用域时,什么都不会发生(它已被移出)。
移动到 s2
中之前:
移动到 s2
中之后:
fn main() { let s1: String = String::from("Rust"); let s2: String = s1; }
s1
中的堆数据会被 s2
重复使用。s1
离开作用域时,什么都不会发生(它已被移出)。移动到 s2
中之前:
移动到 s2
中之后: