Skip to content

Listing 17-18 fails to mention required use statement #4275

@ostkamp

Description

@ostkamp

URL to the section(s) of the book with this problem:

https://doc.rust-lang.org/book/ch17-03-more-futures.html

Description of the problem:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions