Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
644: Implement `PeekingNext` for `PeekingTakeWhile`. r=jswrenn a=olson-sean-k 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). Co-authored-by: Sean Olson <[email protected]>
- Loading branch information