I am somewhat baffled. I am trying to compile and run the code from the crossbeam::thread example at the top of the page here. I believe I have added the correct headers to use crossbeam. My code looks like this:
extern crate crossbeam;
use crossbeam::crossbeam_utils::thread;
fn main() {
let people = vec![
"Alice".to_string(),
"Bob".to_string(),
"Carol".to_string(),
];
thread::scope(|s| {
for person in &people {
s.spawn(move |_| {
println!("Hello, {}!", person);
});
}
}).unwrap();
}
but I get an error that reads:
**error[E0603]** **: extern crate `crossbeam_utils` is private**
**-->** src/main.rs:3:16
**|**
**3** **|** use crossbeam::crossbeam_utils::thread;
**|** **^^^^^^^^^^^^^^^**
**error** **: aborting due to previous error**
**For more information about this error, try `rustc --explain E0603`.**
**error:** Could not compile `test-crossbeam`.
the crate crossbeam and the crate crossbeam_utils are different. One way to solve this is by adding crossbeam-utils = "0.6.6" in your Cargo.toml, and then read this:
Thanks, that was it. Dumb beginner mistake. I though that crossbeam was pulling the utils in as well. I really appreciate your help! It is great to get unstuck.
This also explains why the example is a little confusing - when you re-export something from another crate, it retains the original doc comments, including examples. So despite that example showing up in crossbeam's docs, it's actually taken from crossbeam_utils.