Rust 中移動的字串
fn main() { let s1: String = String::from("Rust"); let s2: String = s1; }
- 系統會為
s2重複使用s1的堆積資料。 - 當
s1超出範圍時,系統不會執行任何動作,因為s1已移出。
移至 s2 前:
移至 s2 後:
fn main() { let s1: String = String::from("Rust"); let s2: String = s1; }
s2 重複使用 s1 的堆積資料。s1 超出範圍時,系統不會執行任何動作,因為 s1 已移出。移至 s2 前:
移至 s2 後: