hyperium / hyper

An HTTP library for Rust
https://hyper.rs
MIT License
14.58k stars 1.6k forks source link

Error: use of undeclared type or module `futures_util` #2249

Open JimLynchCodes opened 4 years ago

JimLynchCodes commented 4 years ago

Hi, I straight up copied the echo example and am trying to run it.

I tried putting this in my Cargo.toml [dependencies]

[dependencies]
hyper = "0.13"
tokio = { version = "0.2", features = ["full"] }
futures-core = { version = "0.3", default-features = false }
futures-channel = "0.3"
futures-util = { version = "0.3", default-features = false }

[dev-dependencies]
futures-util = { version = "0.3", default-features = false, features = ["alloc"] }

But when in my IDE and when I try to run it I see these two errors:

error[E0433]: failed to resolve: use of undeclared type or module `futures_util`
 --> src/main.rs:3:5
  |
3 | use futures_util::stream::try_stream::TryStreamExt;
  |     ^^^^^^^^^^^^ use of undeclared type or module `futures_util`
error[E0599]: no method named `map_ok` found for struct `hyper::body::body::Body` in the current scope
  --> src/main.rs:21:48
   |
21 |             let chunk_stream = req.into_body().map_ok(|chunk| {
   |                                                ^^^^^^ method not found in `hyper::body::body::Body`
   |
   = 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:
   |
3  | use futures_util::stream::try_stream::TryStreamExt;
   |
AyWa commented 4 years ago

I had same issue: maybe https://github.com/hyperium/hyperium.github.io/pull/60 can help

SergeiMinaev commented 4 years ago

If someone is stuck with "use of undeclared type or module futures_util", replace line use futures_util::TryStreamExt; with use futures::stream::TryStreamExt;

(Rust version - 1.46)