mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-24 08:00:24 +08:00
25 lines
990 B
Plaintext
25 lines
990 B
Plaintext
|
$ cargo run
|
||
|
Compiling shared-state v0.1.0 (file:///projects/shared-state)
|
||
|
error[E0277]: `Rc<Mutex<i32>>` cannot be sent between threads safely
|
||
|
--> src/main.rs:11:22
|
||
|
|
|
||
|
11 | let handle = thread::spawn(move || {
|
||
|
| ______________________^^^^^^^^^^^^^_-
|
||
|
| | |
|
||
|
| | `Rc<Mutex<i32>>` cannot be sent between threads safely
|
||
|
12 | | let mut num = counter.lock().unwrap();
|
||
|
13 | |
|
||
|
14 | | *num += 1;
|
||
|
15 | | });
|
||
|
| |_________- within this `[closure@src/main.rs:11:36: 15:10]`
|
||
|
|
|
||
|
= help: within `[closure@src/main.rs:11:36: 15:10]`, the trait `Send` is not implemented for `Rc<Mutex<i32>>`
|
||
|
= note: required because it appears within the type `[closure@src/main.rs:11:36: 15:10]`
|
||
|
|
||
|
error: aborting due to previous error
|
||
|
|
||
|
For more information about this error, try `rustc --explain E0277`.
|
||
|
error: could not compile `shared-state`
|
||
|
|
||
|
To learn more, run the command again with --verbose.
|