-
Notifications
You must be signed in to change notification settings - Fork 341
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
adds stream::fold combinator #180
Conversation
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.
LGTM -- going to leave it to @stjepang for the final review. We're two weeks out from needing to stabilize our full API so this might be held up for a little bit.
there is no aim at implementing all combinators in Stream before that, right? |
I think you've been doing fantastic work, and would be saddened to stop these PRs from going through. Though making sure we feel confident in what we stabilize is really important. Perhaps a middle ground would be to start adding unstable markers to new streams combinators. The way to do that is to add the following above each methods / struct: #[cfg_attr(feature = "docs", doc(cfg(unstable)))] This way we can keep working on porting over the full API surface, but without needing to worry it needs to be stable for the 1.0 release (and importantly: not adding additional API surface for @stjepang to review in the next two weeks). @stjepang How do you feel about this? Do you think this could work? |
src/stream/stream/fold.rs
Outdated
|
||
impl<S, F, B> Future for FoldFuture<S, F, S::Item, B> | ||
where | ||
S: Stream + Unpin + Sized, |
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 think we don't need Unpin
here.
src/stream/stream/fold.rs
Outdated
|
||
match next { | ||
Some(v) => { | ||
cx.waker().wake_by_ref(); |
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.
Instead of waking ourselves on every step, let's turn this into a loop instead and implement poll()
like here:
https://github.com/rust-lang-nursery/futures-rs/blob/master/futures-util/src/stream/fold.rs
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.
Thanks! :)
bors r+ |
180: adds stream::fold combinator r=stjepang a=montekki Fold. Kind of clumsy around the part with the option and moving out of the shared context. ___ Stdlib: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.fold Ref: #129 Co-authored-by: Fedor Sakharov <[email protected]>
Build succeeded
|
Fold. Kind of clumsy around the part with the option and moving out of the shared context.
Stdlib: https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.fold
Ref: #129