-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add enumerate combinator to Stream #832
Add enumerate combinator to Stream #832
Conversation
Sorry for my comment here since I'm not a maintainer of any kind, but I think this belongs into the |
@NeoLegends the issue is in this repository, so I thought that it can go here. Also, there is |
@zaharidichev Given that futures-rs is primarily targeted at Futures 0.3/std and Tokio isn't, I think Tokio is a good place to open a PR, but @carllerche can correct me. |
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.
These changes look good to me, but I wonder if it makes sense to have a corresponding Sink
implementation in the same way that Fuse.
@davidbarsky The reason I did not put a forwarding sink impl is because I saw that |
Accident of history, as far as I can tell, but others can more clearly explain. |
thanks for the explanation @davidbarsky. I have added a sink impl |
Thanks @zaharidichev! I think this looks good. I can merge if build succeeds, @carllerche? |
Thanks @davidbarsky Since I am a bit new to this repo, is there some other biginner friendly ticket I can pick up ? |
@zaharidichev Anything under the label “Help Wanted”. In my opinion, the biggest return on effort (and the best way to go from “beginner” to “expert” extremely quickly) is documentation. Issues are tracked at tokio-rs/doc-push, and picking one of those issues up and opening a PR on https://github.com/tokio-rs/website would be extremely helpful. |
Yes, documentation sounds like a good way to self educate. I will pick something up from there :) Thanks ! |
I wonder why the build is showing as in progress when it actually failed on stable ? |
@zaharidichev seems like the travis forgot to update the commit but it seems that |
Yes @LucioFranco, sorry about that. It passes now. |
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.
Overall this LGTM 👍
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 👍 Just some minor requests inline.
src/util/stream.rs
Outdated
@@ -9,7 +9,7 @@ use futures::Stream; | |||
|
|||
#[cfg(feature = "timer")] | |||
use std::time::Duration; | |||
|
|||
use util::enumerate::Enumerate; |
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 this needs to be a pub
export.
src/util/enumerate.rs
Outdated
} | ||
|
||
impl<T> Enumerate<T> { | ||
pub fn new(stream: T) -> Self { |
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.
Can we avoid making this public? Construction can happen via the stream trait.
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.
Sorry, not entirely sure how that works. Can you give me a clue. Essentially we need to make it module private but how does that tie in with the pub export that you mentioned earlier ?
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.
pub(crate) fn new(...)
then call Enumerate::new
in `StreamExt::enumerate().
@carllerche I think I have addressed your comments. Is this good to merge now ? |
@zaharidichev Just one missing pub here then it should be good. (the |
@carllerche Can that be merged now ? |
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.
👍
Motivation
Motivation is to provide an enumarete combinator, much like in Iterator. The issue for that can be found here: #741
Solution
Simply provided
Stream::enumerate
onStreamExt
Since this is my first PR any kind of feedback will be greatly appreaciated :)