Skip to content
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

Extend StreamExt with state type parameter #5

Merged
merged 1 commit into from
Jul 26, 2017

Conversation

djc
Copy link
Contributor

@djc djc commented Jul 24, 2017

@sfackler what do you think of something like this? I wanted this so I can use futures::stream::iter() but for a StateStream; this seemed like a neater solution than copying iter().

src/lib.rs Outdated
self.0.poll().map(|a| {
match a {
Async::Ready(Some(i)) => Async::Ready(StreamEvent::Next(i)),
Async::Ready(None) => Async::Ready(StreamEvent::Done(())),
Async::Ready(None) => Async::Ready(StreamEvent::Done(self.1.take().unwrap())),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you replace the unwrap with an expect("poll called after completion") or something like that?

@sfackler
Copy link
Owner

Sounds reasonable to me!

@djc
Copy link
Contributor Author

djc commented Jul 24, 2017

Good call, amended to include that change. (I seem to have trouble keeping my rustfmt install running, so it might not be formatted according to your standards -- sorry.)

@sfackler
Copy link
Owner

Thanks!

@sfackler sfackler merged commit be43eaa into sfackler:master Jul 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants