mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2024-11-14 04:41:49 +08:00
19 lines
741 B
Plaintext
19 lines
741 B
Plaintext
$ cargo run
|
|
Compiling threads v0.1.0 (file:///projects/threads)
|
|
error[E0382]: use of moved value: `v`
|
|
--> src/main.rs:10:10
|
|
|
|
|
4 | let v = vec![1, 2, 3];
|
|
| - move occurs because `v` has type `Vec<i32>`, which does not implement the `Copy` trait
|
|
5 |
|
|
6 | let handle = thread::spawn(move || {
|
|
| ------- value moved into closure here
|
|
7 | println!("Here's a vector: {v:?}");
|
|
| - variable moved due to use in closure
|
|
...
|
|
10 | drop(v); // oh no!
|
|
| ^ value used here after move
|
|
|
|
For more information about this error, try `rustc --explain E0382`.
|
|
error: could not compile `threads` (bin "threads") due to 1 previous error
|