Hi! I have been working my way through the Rust Book and have found it to be an incredibly helpful, but as I am implementing the multi-threaded web server project from Chapter 20, I am getting errors that don't seem to occur in the examples, specifically listing 20-20. I have used diff to make sure that my code matches the listings in the book, but the unwrap for the Receiver seems to fail for any worker but the first.
Here is my terminal output when I use cargo run:
~/projects/rust_book/hello𓃯 cargo run
warning: field is never read: `workers`
--> src/lib.rs:7:5
|
7 | workers: Vec<Worker>,
| ^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: field is never read: `id`
--> src/lib.rs:48:5
|
48 | id: usize,
| ^^^^^^^^^
warning: field is never read: `thread`
--> src/lib.rs:49:5
|
49 | thread: thread::JoinHandle<()>,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: 3 warnings emitted
Finished dev [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/main`
Worker 1 got a job; executing.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/lib.rs:55:23
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
Worker 0 got a job; executing.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
thread 'Worker 0 got a job; executing.
<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
Worker 0 got a job; executing.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
Worker 0 got a job; executing.
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: RecvError', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"', src/lib.rs:55:23
I am currently running the following OS and rust version:
stable-x86_64-apple-darwin (default)
rustc 1.45.2 (d3fb005a3 2020-07-31)
Is this a new issue?