mirror of
https://github.com/KaiserY/trpl-zh-cn
synced 2024-11-13 03:21:20 +08:00
19 lines
736 B
Plaintext
Executable File
19 lines
736 B
Plaintext
Executable File
$ cargo run
|
|
Compiling equal-to-x v0.1.0 (file:///projects/equal-to-x)
|
|
error[E0382]: borrow of moved value: `x`
|
|
--> src/main.rs:6:40
|
|
|
|
|
2 | let x = vec![1, 2, 3];
|
|
| - move occurs because `x` has type `Vec<i32>`, which does not implement the `Copy` trait
|
|
3 |
|
|
4 | let equal_to_x = move |z| z == x;
|
|
| -------- - variable moved due to use in closure
|
|
| |
|
|
| value moved into closure here
|
|
5 |
|
|
6 | println!("can't use x here: {:?}", x);
|
|
| ^ value borrowed here after move
|
|
|
|
For more information about this error, try `rustc --explain E0382`.
|
|
error: could not compile `equal-to-x` due to previous error
|