mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2024-11-14 21:11:31 +08:00
22 lines
901 B
Plaintext
22 lines
901 B
Plaintext
$ cargo run
|
|
Compiling ownership v0.1.0 (file:///projects/ownership)
|
|
error[E0382]: borrow of moved value: `s1`
|
|
--> src/main.rs:5:15
|
|
|
|
|
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 |
|
|
5 | println!("{s1}, world!");
|
|
| ^^^^ 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-backtrace for 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 `ownership` (bin "ownership") due to 1 previous error
|