rust-lang / futures-rs

Zero-cost asynchronous programming in Rust
https://rust-lang.github.io/futures-rs/
Apache License 2.0
5.38k stars 622 forks source link

Make access inner of futures::io::{BufReader,BufWriter} not require inner trait bound #2848

Closed ethe closed 6 months ago

ethe commented 6 months ago

Currently, accessing the inner of futures::io::{BufReader, BufWriter} requires that the inner type implements AsyncRead or AsyncWrite. This constraint is much stricter than the semantics of inner access require. Removing the trait bound would be helpful in cases where pass-through functions simply obtain a reference to the inner I/O object for further use, without having to specify the inner trait bound explicitly.

taiki-e commented 6 months ago

Thanks for the PR. I'm in favor of accepting this as std::io::BufReader does the same thing. https://doc.rust-lang.org/nightly/std/io/struct.BufReader.html

That said, I think it would be good to remove the bound from not only these accessors, but also from non constructor methods such as buffer, as std::io::BufReader does.

ethe commented 6 months ago

I totally agree, I do the same thing on other non custructor methods just now.