mirror of
https://github.com/rust-lang/book.git
synced 2026-11-30 21:41:18 -06:00
Merge pull request #396 from kberov/outdated-move-error
details in error E0382 changed over time
This commit is contained in:
@@ -364,14 +364,16 @@ You’ll get an error like this because Rust prevents you from using the
|
|||||||
invalidated reference:
|
invalidated reference:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
5:22 error: use of moved value: `s1` [E0382]
|
error[E0382]: use of moved value: `s1`
|
||||||
println!("{}", s1);
|
--> src/main.rs:4:27
|
||||||
^~
|
|
|
||||||
5:24 note: in this expansion of println! (defined in <std macros>)
|
3 | let s2 = s1;
|
||||||
3:11 note: `s1` moved here because it has type `collections::string::String`,
|
| -- value moved here
|
||||||
which is moved by default
|
4 | println!("{}, world!",s1);
|
||||||
let s2 = s1;
|
| ^^ value used here after move
|
||||||
^~
|
|
|
||||||
|
= note: move occurs because `s1` has type `std::string::String`,
|
||||||
|
which does not implement the `Copy` trait
|
||||||
```
|
```
|
||||||
|
|
||||||
If you’ve heard the terms “shallow copy” and “deep copy” while working with
|
If you’ve heard the terms “shallow copy” and “deep copy” while working with
|
||||||
|
|||||||
Reference in New Issue
Block a user