Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ch10/ch10-render-hex-threadpool: does not match Listing 10.28, or compile #103

Closed
ewenmcneill opened this issue Jan 12, 2023 · 1 comment

Comments

@ewenmcneill
Copy link

Quote from book (page 358 of PDF): "The following listing focuses on the parse() function. The rest of the code is the same as listing 10.18. You’ll find the code for the following listing in ch10/ch10-render-hex- threadpool/src/main.rs."

Attempting to compile ch10/ch10-render-hex-threadpool fails because the changes in Listing 10.28 do not actually seem to have been made in the sample code provided.

I'd make a PR, but the book author has advised he will not accept PRs so there doesn't seem much point.

For anyone finding this and having the same problem, you want to make the use declarations in ch10/ch10-render-hex-threadpool/main.rs actually match Listing 10.28, then it will compile. (I haven't checked the rest of the code in main.rs matches Listing 10.28.)

ewen@basadi:~/misc/src/rust/rust-in-action/code/ch10/ch10-render-hex-threadpool$ git diff src
diff --git a/ch10/ch10-render-hex-threadpool/src/main.rs b/ch10/ch10-render-hex-threadpool/src/main.rs
index 55dfd87..5ab02fb 100644
--- a/ch10/ch10-render-hex-threadpool/src/main.rs
+++ b/ch10/ch10-render-hex-threadpool/src/main.rs
@@ -1,6 +1,7 @@
+use std::thread;
 use std::env;
 
-use rayon::prelude::*;
+use crossbeam::channel::{unbounded};
 use svg::node::element::path::{Command, Data, Position};
 use svg::node::element::{Path, Rectangle};
 use svg::Document;
ewen@basadi:~/misc/src/rust/rust-in-action/code/ch10/ch10-render-hex-threadpool$ 

Ewen

build failure for ch10/ch10-render-hex-threadpool
ewen@basadi:~/misc/src/rust/rust-in-action/code/ch10/ch10-render-hex-threadpool$ cargo build
   Compiling autocfg v0.1.7
   Compiling semver-parser v0.7.0
   Compiling lazy_static v1.4.0
   Compiling cfg-if v0.1.10
   Compiling scopeguard v1.0.0
   Compiling svg v0.6.0
   Compiling semver v0.9.0
   Compiling crossbeam-utils v0.7.0
   Compiling crossbeam-epoch v0.8.0
   Compiling rustc_version v0.2.3
   Compiling memoffset v0.5.3
   Compiling crossbeam-channel v0.4.0
   Compiling crossbeam-queue v0.2.0
   Compiling crossbeam-deque v0.7.2
   Compiling crossbeam v0.7.3
   Compiling render-hex v0.1.0 (/Users/ewen/misc/src/rust/rust-in-action/code/ch10/ch10-render-hex-threadpool)
error[E0433]: failed to resolve: use of undeclared crate or module `rayon`
 --> src/main.rs:3:5
  |
3 | use rayon::prelude::*;
  |     ^^^^^ use of undeclared crate or module `rayon`

error[E0433]: failed to resolve: use of undeclared crate or module `thread`
   --> src/main.rs:151:7
    |
151 |       thread::spawn(move || {
    |       ^^^^^^ use of undeclared crate or module `thread`

error[E0425]: cannot find function `unbounded` in this scope
   --> src/main.rs:136:28
    |
136 |   let (todo_tx, todo_rx) = unbounded();           // <5>
    |                            ^^^^^^^^^ not found in this scope
    |
help: consider importing this function
    |
1   | use crossbeam::unbounded;
    |

error[E0425]: cannot find function `unbounded` in this scope
   --> src/main.rs:137:34
    |
137 |   let (results_tx, results_rx) = unbounded();     // <6>
    |                                  ^^^^^^^^^ not found in this scope
    |
help: consider importing this function
    |
1   | use crossbeam::unbounded;
    |

Some errors have detailed explanations: E0425, E0433.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `render-hex` due to 4 previous errors
ewen@basadi:~/misc/src/rust/rust-in-action/code/ch10/ch10-render-hex-threadpool$
@ewenmcneill
Copy link
Author

Closing issue to clean up my GitHub "issues created" list, since after 18 months it seems clear nothing will happen in this Rust book related repo with the open issues.

Ewen

@ewenmcneill ewenmcneill closed this as not planned Won't fix, can't repro, duplicate, stale Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant