Skip to content

Conversation

Philippe-Cholet
Copy link
Member

@Philippe-Cholet Philippe-Cholet commented Nov 6, 2023

Related to #792
To make Intersperse[With] adaptors lazy, I use a nested option which is what core::iter::Peekable uses internally.

EDITs: I certainly hope that it's okay to use a nested option in such case because I did a similar thing to make Product lazy (fixing cartesian_product and iproduct! un-laziness) and make CoalesceBy lazy (fixing 5 methods) that I'll publish once this PR is merged.

element: ElemF,
iter: Fuse<I>,
peek: Option<I::Item>,
peek: Option<Option<I::Item>>,
Copy link
Member

Choose a reason for hiding this comment

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

With the added nesting, could you just write a comment here about how the value of peek should be interpreted? (None, Some(None), Some(Some(...))?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done. And I will do the same for Product and CoalesceBy before publishing their similar laziness fix.

@jswrenn jswrenn added this to the next milestone Nov 13, 2023
Similar to what is done by `core::iter::Peekable`, a nested option is now used.
@jswrenn jswrenn added this pull request to the merge queue Nov 13, 2023
Merged via the queue into rust-itertools:master with commit d7e6bab Nov 13, 2023
@Philippe-Cholet Philippe-Cholet deleted the intersperse-laziness branch November 13, 2023 17:50
@jswrenn jswrenn mentioned this pull request Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants