actix / book

Actix user guides

Home Page:https://actix.rs/docs/actix

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Example does not build

akhi3030 opened this issue · comments

The example listed in https://actix.rs/book/actix/sec-2-actor.html#complete-example does not build for me. I saw two problems:

  • I had to update the Cargo.toml file to include a dependency on the futures crate.

  • I see the following compiler error after adding the dependency on the futures crate:

  Compiling actor-ping v0.1.0 (/home/akhi/projects/actor-ping)
warning: unused import: `futures::Future`
 --> src/main.rs:2:5
  |
2 | use futures::Future;
  |     ^^^^^^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

error[E0599]: no method named `map` found for type `actix::address::message::Request<MyActor, Ping>` in the current scope
  --> src/main.rs:52:14
   |
52 |             .map(|res| match res {
   |              ^^^ method not found in `actix::address::message::Request<MyActor, Ping>`
   |
   = note: the method `map` exists but the following trait bounds were not satisfied:
           `&mut actix::address::message::Request<MyActor, Ping> : futures::stream::Stream`
           `&mut actix::address::message::Request<MyActor, Ping> : std::iter::Iterator`
   = help: items from traits can only be used if the trait is in scope
help: the following trait is implemented but not in scope; perhaps add a `use` for it:
   |
1  | use futures::future::Future;
   |

error: aborting due to previous error

For more information about this error, try `rustc --explain E0599`.
error: could not compile `actor-ping`.

To learn more, run the command again with --verbose.

The version I am using is:

$ cargo --version
cargo 1.41.0

I think you're using the different versions of the dependencies, see https://github.com/actix/book/blob/master/Cargo.toml for what we expect.

Thanks for the clarification. I was just following the instructions in the book in particular as described in https://actix.rs/book/actix/sec-1-getting-started.html. Might be worth updating the list of dependencies there.

I'd prefer to update the docs to actix 0.9/0.10-alpha rather than tweak the list. We're tracking that progress here: #44