-
Notifications
You must be signed in to change notification settings - Fork 309
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
#711
Merge Merge/MergeBy/MergeJoinBy
implementations
#711
Conversation
To get rid of `const SAME: bool`, I wrap the function `F` in `MergeFuncLR` and `MergeFuncT`. Those `MergeFuncLR/T` have a parameter `T` (phantom field) to not have conflicting implementations of `MergePredicate<L, R>`. In `merge_join_by` definition, in order for the compiler to keep guessing left/right types, I kept `F: FnMut(&Self::Item, &J::Item) -> T`. But to not add `F: MergePredicate<Self::Item, J::Item>` that felt duplicate, I removed `T: OrderingOrBool...`, the user might lose `OrderingOrBool` information.
And I simplify `MergeFuncLR` and `MergeFuncT` to "tuple structs".
Basically because `PutBack<Fuse<I>>` is fused no matter if `I` is or not. Same for `J`.
Hi @Philippe-Cholet, thanks for this. I try to pick this up, but I am very unsure that |
@phimuemue A bit disappointed, I started again and to my own surprise I quickly found a way (fresh eyes I guess). So 0a3f122 |
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. |
Merge
andMergeBy
are moved from "adaptors" to "merge_join" modules.Then
Merge
,MergeBy
andMergeJoinBy
are now instances of a new (common and private) struct:InternalMergeJoinBy
.Internally, instead of
OrderingOrBool
andFnMut(&L, &R) -> Out
, we useMergePredicate<L, R, Out=...>
(Out
beingOrdering
orbool
).And with
MergeFuncT
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.