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

Add StreamExt::scan #2044

Merged
merged 4 commits into from Jan 21, 2020
Merged

Add StreamExt::scan #2044

merged 4 commits into from Jan 21, 2020

Conversation

@olegnn
Copy link
Contributor

olegnn commented Jan 20, 2020

This PR adds combinator similar to https://doc.rust-lang.org/std/iter/trait.Iterator.html#method.scan.
It may be useful for some cases when it's needed to cut stream or transform one stream into another using some state-based computations.

@olegnn olegnn changed the title Added StreamExt::scan Add StreamExt::scan Jan 20, 2020
olegnn added 2 commits Jan 20, 2020
/// ```
fn scan<S, B, Fut, F>(self, initial_state: S, f: F) -> Scan<Self, S, Fut, F>
where
F: FnMut(&mut S, Self::Item) -> Fut,

This comment has been minimized.

Copy link
@cramertj

cramertj Jan 21, 2020

Member

There isn't a way to fix this at the moment, sadly, but this is subtly the wrong method signature for this function, because it doesn't allow Fut to hold onto &mut S. There's no way to fix this right now due to limitations of HRTBs / GATs, so I don't mind accepting this PR now, but note that this makes this API dramatically less useful than it could be otherwise.

@cramertj cramertj merged commit 6b0e6dc into rust-lang:master Jan 21, 2020
1 check failed
1 check failed
Travis CI - Pull Request Build Failed
Details
@cramertj

This comment has been minimized.

Copy link
Member

cramertj commented Jan 21, 2020

Thanks for the PR! If you have time to send a PR to add documentation about the restriction I listed above, that'd be perfect, but no worries if not!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.