You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's quite common to want to create a stream from an iterator. Currently we're having a lot of VecDequeue in our examples because it implements Stream, but that might not stay around (see rust-lang/futures-rs#1879).
So I propose we add a new function stream::from_iter that returns a struct FromIter, similar to how we have stream::from_fn that returns FromFn.
This is mostly as a pragmatic fix for the fact that we can't implement IntoStream for std types ourselves (see #129), and probably in general useful when porting codebases. The value of this function should decrease if we can resolve that, but in order to do so the VecDequeue must be removed first, so in order to break the somewhat recursive dependency there I propose we add this function.
Because we'd want to use this function to replace all uses of VecDequeue we currently have in our examples, and we're in somewhat of time pressure (futures@0.3.0 is in 9 days), I'd like to propose we make an exception here and introduce this without the "unstable" marker.
edit: unsure about stability. More in follow-up comment.
Riffing on this more: actually the preferred outcome would be to have
impl<I: Iterator> IntoStream for I
We currently can't do this, but such a bound seems like it'd be ideal. That way any Iterator impl could be converted to a stream, yet into_iter and into_stream methods could co-exist on any given type. This would also remove the need for stream::from_iter, which admittedly isn't quite what we want.
Actually I'm wondering if instead of instant-stabilizing stream::from_iter we can introduce this as "unstable" for doc purposes. We could then punt stabilizing this (or removing it entirely) for later. Or perhaps we stabilize it and revisit this for any possible 2.0 release. Unsure, but would be keen to hear thoughts. Thanks!
It's quite common to want to create a stream from an iterator. Currently we're having a lot of
VecDequeue
in our examples because it implementsStream
, but that might not stay around (see rust-lang/futures-rs#1879).So I propose we add a new function
stream::from_iter
that returns a structFromIter
, similar to how we havestream::from_fn
that returnsFromFn
.This is mostly as a pragmatic fix for the fact that we can't implement
IntoStream
for std types ourselves (see #129), and probably in general useful when porting codebases. The value of this function should decrease if we can resolve that, but in order to do so theVecDequeue
must be removed first, so in order to break the somewhat recursive dependency there I propose we add this function.Because we'd want to use this function to replace all uses of
VecDequeue
we currently have in our examples, and we're in somewhat of time pressure (futures@0.3.0
is in 9 days),I'd like to propose we make an exception here and introduce this without the."unstable"
markeredit: unsure about stability. More in follow-up comment.
cc/ @stjepang
Examples
The text was updated successfully, but these errors were encountered: