-
Notifications
You must be signed in to change notification settings - Fork 343
Open
@Ppjet6
Description
Steps to reproduce
futures-preview = { version = "0.3.0-alpha.19", features = [ "async-await" ] }
inCargo.toml
as recommended in §3.1.- Try to build the example in https://book.async.rs/tutorial/sending_messages.html
use futures::channel::mpsc; // 1 use futures::sink::SinkExt; use std::sync::Arc; type Sender<T> = mpsc::UnboundedSender<T>; // 2 type Receiver<T> = mpsc::UnboundedReceiver<T>; async fn connection_writer_loop( mut messages: Receiver<String>, stream: Arc<TcpStream>, // 3 ) -> Result<()> { let mut stream = &*stream; while let Some(msg) = messages.next().await { stream.write_all(msg.as_bytes()).await?; } Ok(()) }
What happens
error[E0599]: no method named `next` found for type `futures_channel::mpsc::UnboundedReceiver<std::string::String>` in the current scope
--> core/src/main.rs:89:36
|
89 | while let Some(msg) = messages.next().await {
| ^^^^ method not found in `futures_channel::mpsc::UnboundedReceiver<std::string::String>`
|
= note: the method `next` exists but the following trait bounds were not satisfied:
`futures_channel::mpsc::UnboundedReceiver<std::string::String> : async_std::stream::stream::StreamExt`
= 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:
|
7 | use futures_util::stream::StreamExt;
|
It seems to work with futures = "0.3.0"
, and it's indeed what is being used in the a-chat
example in the repo as of 122e873.