PS E:\rust-test\hello> cargo run Compiling hello v0.1.0 (E:\rust-test\hello) error[E0382]: borrow of moved value: `param` --> src\main.rs:5:25 | 2 | let param = String::from("hello"); | -----move occurs because `param` has type `String`, which does not implement the `Copy` trait 3 | owner_change(param); | ----- value moved here 4 | 5 | println!("value: {}", param); // 报错;param 的所有权已经转移到其他地方,因此这里不能再次使用了 ... | ^^^^^ value borrowed here after move | note: consider changing this parametertypeinfunction `owner_change` toborrowinsteadifowningthevalueisn'tnecessary --> src\main.rs:9:20 | 9 | fn owner_change(v: String) { | ------------ ^^^^^^ this parameter takes ownership of the value | | | in this function = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtracefor more info) help: consider cloning the value if the performance cost is acceptable | 3 | owner_change(param.clone()); | ++++++++
For more information about this error, try `rustc --explain E0382`. error: could not compile `hello` (bin "hello") due to previous error PS E:\rust-test\hello>
PS E:\rust-test\hello> cargo run Compiling hello v0.1.0 (E:\rust-test\hello) error[E0382]: borrow of moved value: `s1` --> src\main.rs:4:30 | 2 | let s1 = String::from("hello"); | --move occurs because `s1` has type `String`, which does not implement the `Copy` trait 3 | let s2 = s1; | -- value moved here 4 | println!("s1: {}, s2: {}", s1, s2); | ^^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtracefor more info) help: consider cloning the value if the performance cost is acceptable | 3 | let s2 = s1.clone(); | ++++++++
For more information about this error, try `rustc --explain E0382`. error: could not compile `hello` (bin "hello") due to previous error PS E:\rust-test\hello>