|
|
@ -195,7 +195,7 @@ fn main() {
|
|
|
|
let s1 = String::from("hello,");
|
|
|
|
let s1 = String::from("hello,");
|
|
|
|
let s2 = String::from("world!");
|
|
|
|
let s2 = String::from("world!");
|
|
|
|
// 在下句中,s1的所有权被转移走了,因此后面不能再使用s1
|
|
|
|
// 在下句中,s1的所有权被转移走了,因此后面不能再使用s1
|
|
|
|
let s3 = s1 + &s2; // note s1 has been moved here and can no longer be used
|
|
|
|
let s3 = s1 + &s2;
|
|
|
|
assert_eq!(s3,"hello,world!");
|
|
|
|
assert_eq!(s3,"hello,world!");
|
|
|
|
// 下面的语句如果去掉注释,就会报错
|
|
|
|
// 下面的语句如果去掉注释,就会报错
|
|
|
|
// println!("{}",s1);
|
|
|
|
// println!("{}",s1);
|
|
|
|