Skip to content

Potential little issue of 17.5 A Closer Look at the Traits for Async #4398

Open
@Erik-Sovereign

Description

@Erik-Sovereign

https://doc.rust-lang.org/book/ch17-05-traits-for-async.html#the-stream-trait

First of all: Thank you for the excellent chapter about Async Rust.

In the last paragraphs it is written
"In the version of StreamExt used in the trpl crate, the trait not only defines the next method but also supplies a default implementation of next that correctly handles the details of calling Stream::poll_next. This means that even when you need to write your own streaming data type, you only have to implement Stream, and then anyone who uses your data type can use StreamExt and its methods with it automatically."

This is potentially wrong or atleast unclear to me.
It states "In the version of StreamExt used in the trpl crate" but the trpl crate just reexports the standard StreamExt of tokio-stream. In tokio-stream in stream_ext.rs I see a implementation of next but I see no additional "default implementation of next that correctly handles the details of calling Stream::poll_next". Maybe the standard implementation of next is exactly this default implementation. If this is the case, I don't understand why it is written like that.

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