Skip to content

Conversation

/// 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 {
Copy link
Member Author

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.

Copy link
Member Author

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 
/// 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 {
Copy link
Member Author

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.

Copy link
Member

@yoshuawuyts yoshuawuyts left a 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!

@cramertj
Copy link
Member

cramertj commented Sep 3, 2019

Nice! Seems like a good easy add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants