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

Implement PeekingNext for PeekingTakeWhile. #644

Merged
merged 1 commit into from
Jun 15, 2023

Conversation

olson-sean-k
Copy link
Contributor

This PR implements PeekingNext for PeekingTakeWhile by composing its predicate with the predicate given to PeekingNext::peeking_next. This allows Itertools::peeking_take_while to be chained and for subsequent calls, including those across function boundaries, to function as expected while restoring items in the originating iterator.

See also #643, which implements PeekingNext for mutable references. In combination, these changes allow code to generically accept types implementing PeekingNext where Itertools::peeking_take_while can be used by the caller to prepare an iterator and subsequently by a function where restoring items in the originating iterator is important (i.e., the function cannot simply use Iterator::peekable etc., because Iterator::next would unconditionally be called on the originating iterator).

This change implements `PeekingNext` for `PeekingTakeWhile` by composing
its predicate with the predicate given to `PeekingNext::peeking_next`.
This allows subsequent (and chained) calls to functions that require
`PeekingNext` following `Itertools::peeking_take_while`.
Copy link
Member

@jswrenn jswrenn left a comment

Choose a reason for hiding this comment

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

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 15, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 8184e4c into rust-itertools:master Jun 15, 2023
@jswrenn jswrenn modified the milestones: next, v11.0.0 Nov 13, 2023
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