Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

§3.4 (Sending Messages) in the book requires a different version of futures #495

Open
Labels
documentationImprovements or additions to documentation good first issueGood for newcomers
@Ppjet6

Description

Steps to reproduce

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation good first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /