TryStream bound for SinkExt::send_all #2024
Labels
A-sink
Area: futures::sink
S-needs-decision
Status: A decision on whether or not to do this is needed.
Milestone
I noticed that recently send_all signature was updated to require TryStream bound on passed stream (#1946).
I wonder if there is a reason for this restriction?
Consider the following code that I have:
This fails with following error:
Took me some time to decrypt that this happens because stream::iter::Iter does not implement TryStream and gets automatic implementation only if stream's item is std::result::Result. So, in simple code above I have to wrap each message into Ok like
futures::stream::iter(vec![Ok(msg1), Ok(msg2)])
which looks weird.Shouldn't it be possible to send streams that produce items for sure and can't fail? Unless I am missing something obvious that makes it undesirable/not possible, I think sinking collection of values is rather often use case.
The text was updated successfully, but these errors were encountered: