I have been familiarizing myself with Streams since my project at work makes heavy use of iterations that involve async I/O (such as transforming datasets containing transformations that require API calls to resolve). One thing I noticed was that, unlike sync iterators, streams require you to use .try_collect to collect into a Result. I found the following reply to an issue discussing the same topic from before async fn in traits was stabilized:
Collecting into a Result<Collection<_>, _> specifically can be done via try_collect.
It could be possible to add a trait like FromStream as an equivalent to FromIterator to use instead of Default + Extend, but that would want to involve async fn-in-traits, which is not possible today (you can see that async-std::stream::FromStream forces boxing of the future and isn't Send, which would be unacceptable long term.
Originally posted by @Nemo157 in #1988
Is there still a blocker to allowing StreamExt::collect to collect into a Result?
I have been familiarizing myself with Streams since my project at work makes heavy use of iterations that involve async I/O (such as transforming datasets containing transformations that require API calls to resolve). One thing I noticed was that, unlike sync iterators, streams require you to use
.try_collectto collect into aResult. I found the following reply to an issue discussing the same topic from beforeasync fnin traits was stabilized:Originally posted by @Nemo157 in #1988
Is there still a blocker to allowing
StreamExt::collectto collect into aResult?