You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Listing 17-18 fails to mention required use statement #4275
The 2-line code excerpt in Listing 17-18 shown on the page linked above fails to compile when integrated into the source snippets derived from earlier example listings.
This is because a "use" statement for "Pin" is missing (see compiler output below).
Note the full code where the 2 lines are an excerpt of contains another use statement also dealing with "Pin" but that code is of course not visible to the reader of this book page. There is no mentioning of "Pin" in earlier parts of chapter 17.
$ cargo build
Compiling async_channel_4 v0.1.0 (/home/ostkamp/rust/projects/17_Fundamentals_of_Async_Programming/async_channels_4)
error[E0412]: cannot find type `Pin` in this scope
--> src/main.rs:59:26
|
59 | let futures: Vec<Pin<Box<dyn Future<Output = ()>>>> = vec![Box::pin(tx1_fut), Box::pin(rx_fut), Box::pin(tx_fut)];
| ^^^ not found in this scope
|
help: consider importing this struct
|
4 + use std::pin::Pin;
|
For more information about this error, try `rustc --explain E0412`.
error: could not compile `async_channel_4` (bin "async_channel_4") due to 1 previous error
Suggested fix:
Please include a hint that the "use" statement has to be added to build this.
Activity
chriskrycho commentedon Mar 17, 2025
Ah, thanks for catching this! The same concern applies to the following example for the
pin!macro, too! I’ll put up a fix.Ch. 17: mention `use std::pin::{Pin, pin};` on introduction