-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Stream::size_hint #1853
Add Stream::size_hint #1853
Conversation
@@ -126,7 +165,7 @@ mod private_try_stream { | |||
|
|||
/// A convenience for streams that return `Result` values that includes | |||
/// a variety of adapters tailored to such futures. | |||
pub trait TryStream: private_try_stream::Sealed { | |||
pub trait TryStream: Stream + private_try_stream::Sealed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this bound because it would be convenient if stream.size_hint()
could be called on St: TryStream
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh...
error[E0191]: the value of the associated type `Item` (from the trait `futures_core::stream::Stream`) must be specified
--> futures/tests/object_safety.rs:20:30
|
20 | assert_is_object_safe::<&dyn TryStream<Ok = (), Error = ()>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ associated type `Item` must be specified
@@ -57,7 +57,7 @@ mod private_try_future { | |||
|
|||
/// A convenience for futures that return `Result` values that includes | |||
/// a variety of adapters tailored to such futures. | |||
pub trait TryFuture: private_try_future::Sealed { | |||
pub trait TryFuture: Future + private_try_future::Sealed { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added for consistency with TryStream
.
e2ae231
to
3415a86
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm really into this! Similar to Iterator::size_hint
and poll_read_vectored
this seems like a method that's really useful to significantly help speed up certain code paths!
Nice! Seems like a good easy add. |
Closes #170
r? @cramertj
cc @Nemo157 @seanmonstar @carllerche @LucioFranco @yoshuawuyts