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

Merge Merge/MergeBy/MergeJoinBy implementations (v2) #736

Merged
merged 5 commits into from Sep 20, 2023

Conversation

Philippe-Cholet
Copy link
Member

Cleaner alternative to the experimental/messy #711. Closes #701.
@phimuemue I would additionally rename InternalMergeJoinBy to MergeBy, making MergeJoinBy an alias of MergeBy instead. But I would like your opinion on this first.
I recently found a way to not add a fourth type to MergeJoinBy (added to the old PR) but another difference is that I do not wrap with MergeFuncT anymore.

@Philippe-Cholet Philippe-Cholet changed the title Merge Merge/MergeBy/MergeJoinBy implementations Merge Merge/MergeBy/MergeJoinBy implementations (v2) Aug 27, 2023
src/merge_join.rs Outdated Show resolved Hide resolved
@Philippe-Cholet
Copy link
Member Author

@phimuemue What do you think of this new version?
MergeJoinBy do not have a fourth type here, as you thought possible (the small FuncLR trait that make it work seems reasonable to me).

And the trait `OrderingOrBool<L, R>` is now for wrapped functions rather than for `Ordering` and `bool`.

NOTES:
- The new struct `MergeFuncLR<F, T>` is useful to avoid conflicting implementations of `OrderingOrBool<L, R> for F` because the compiler thinks that `F` could implement both `FnMut(&L, &R) -> Ordering` and `FnMut(&L, &R) -> bool`.
- The new trait `FuncLR<L, R>` is useful to be able to infer the Output type `T` without having to add a fourth parameter to `MergeJoinBy`. From what I understand, this is needed because the `FnMut` trait is not fully stabilized yet.
- `OrderingOrBool<L, R>` has a new associated type `Out`, which is useful in `impl Iterator` because otherwise the compiler would complain about `T` be unconstrained.

This successfully pass the tests.
Being now an alias, we can remove various implementations. `FusedIterator` will be inserted back soon.

We don't need `MergePredicate<T>` anymore because we use two new implementations of `OrderingOrBool<T, T>`.
`I` and `J` are fused by `InternalMergeJoinBy` so we don't need them to implement `FusedIterator`.
@Philippe-Cholet
Copy link
Member Author

Rebased after recent #751.

src/merge_join.rs Outdated Show resolved Hide resolved
Apparently not needed anymore.
@jswrenn jswrenn added this to the next milestone Sep 20, 2023
@jswrenn jswrenn added this pull request to the merge queue Sep 20, 2023
Merged via the queue into rust-itertools:master with commit 6ffdac1 Sep 20, 2023
8 checks passed
@Philippe-Cholet
Copy link
Member Author

That feature was quite a ride for me. 🎉

@jswrenn Note that you are mixing different PRs with the "next" milestone.

@jswrenn
Copy link
Member

jswrenn commented Sep 20, 2023

What do you mean by "mixing"?

We use the next milestone to keep track of highlights that should be noted in the changelog. (Caveat: We haven't been very consistent about doing so, lately.)

@Philippe-Cholet
Copy link
Member Author

Just that old PRs of 0.11 are with the new ones, which I noticed and found weird but if it's not an issue then case closed.

@Philippe-Cholet Philippe-Cholet deleted the issue-701-part2-v2 branch September 20, 2023 15:19
@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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Merge MergeBy and MergeJoinBy
2 participants