Closed Philippe-Cholet closed 1 year ago
Hi @Philippe-Cholet, thanks for this. I try to pick this up, but I am very unsure that MergeJoinBy
really needs a fourth type parameter, so I for now only cherry-picked the first commit here.
@phimuemue A bit disappointed, I started again and to my own surprise I quickly found a way (fresh eyes I guess). So https://github.com/rust-itertools/itertools/pull/711/commits/0a3f122a58cb57c478b4813887e1cfc5a08c0e25 It results in a big type definition but it works.
I'm closing this. This is the result of some useful experiments but became too messy to be properly reviewed and it deserves a cleaner PR I'm currently working on. At least, the first commit has been cherry-picked.
Merge
andMergeBy
are moved from "adaptors" to "merge_join" modules. ThenMerge
,MergeBy
andMergeJoinBy
are now instances of a new (common and private) struct:InternalMergeJoinBy
. Internally, instead ofOrderingOrBool
andFnMut(&L, &R) -> Out
, we useMergePredicate<L, R, Out=...>
(Out
beingOrdering
orbool
). And withMergeFuncT
andMergeFuncLR
also kept private, the functions return those types:The only changes for an external user:
MergeJoinBy
sadly requires now a fourth type (it was that or share the internalMergeFuncLR
publicly).MergeJoinBy
now implementsFusedIterator
too.Closes #701
PS: In
fn merge_join_by
, the constraintT: OrderingOrBool<I::Item, J::Item>,
has been removed. Even if the documentation is clear, we could add it back in some way if you want.