async-std icon indicating copy to clipboard operation
async-std copied to clipboard

Implement Stream::size_hint method on stream utilities

Open taiki-e opened this issue 4 years ago • 4 comments

Most of async-std's stream utilities were written before Stream::size_hint was released and do not implement Stream::size_hint method. This means that async-std's stream utilities may be a bit inefficient than other crates such as futures, tokio-stream, futures-lite, which provide similar utilities.

related: https://github.com/rust-lang/futures-rs/pull/1853, https://github.com/rust-lang/rust/pull/81797

taiki-e avatar Feb 05 '21 19:02 taiki-e

Hey guys I wanted to know if on the size_hint method in the stream trait on the crate, if I should give it a default implementation. Something like below, a default size_hint is implemented in the stream module in the standard library.

fn size_hint(&self) -> (usize, Option) { (0, None) };

mich2000 avatar Mar 21 '21 20:03 mich2000

IIRC, this crate's Stream trait is for documentation, so I think either one is fine.

taiki-e avatar Mar 22 '21 01:03 taiki-e

Okay, I'll directly work on the stream size_hint implementation.

mich2000 avatar Mar 22 '21 21:03 mich2000

PR: https://github.com/async-rs/async-std/pull/967

mich2000 avatar Mar 24 '21 19:03 mich2000