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

Implement DedupBy in terms of Coalesce #440

Merged
merged 10 commits into from Jun 18, 2020
Merged

Conversation

phimuemue
Copy link
Member

@phimuemue phimuemue commented May 18, 2020

During the discussion of #423 (comment), we found that DedupBy/DedupByWithCount could actually be implemented in terms of Coalesce. This simplifies the implementation quite a bit and lets derived adaptors inherit specializations.

  • Implement fold on Coalesce so that all the adaptors derived from it inherit the specialization (currently, only DedupBy has this specialization).
  • Introduce CoalescePredicate (similar to DedupPredicate) to allow for different customizations of Coalesce.
  • Introduce parametrizable CoalesceBy: Base for Coalesce, DedupBy, DedupByWithCount.
  • Implement DedupBy/DedupByWithCount in terms of CoalesceBy (using particular impls).
  • At last, the indirection through CoalesceCore is not needed anymore.

@phimuemue phimuemue changed the title Coalesce Implement DedupBy in terms of Coalesce May 18, 2020
src/adaptors/mod.rs Outdated Show resolved Hide resolved
@jswrenn
Copy link
Member

jswrenn commented Jun 18, 2020

Thanks!

bors r+

@jswrenn jswrenn added this to the next milestone Jun 18, 2020
@bors
Copy link
Contributor

bors bot commented Jun 18, 2020

Build succeeded:

@bors bors bot merged commit a517cfc into rust-itertools:master Jun 18, 2020
bors bot added a commit that referenced this pull request Jul 17, 2020
450: Introduce module coalesce r=jswrenn a=phimuemue

Hi! As #440 (thanks for reviewing and merging, btw) presumably conflicts with any existing PRs touching `coalesce` et al, I thought we could just as well seize the opportunity and move these types into an own module (so to speak as a starting point for the problem mentioned in #423 (comment)).

I cut-pasted `Coalesce` et al into an own module, rearranged the code so that specialized types follow their generic variants, and ran `cargo fmt` on the new module.

I suggest to import the `coalesce` types into `adaptors` similarly to what we already have for `multi_product`.

Co-authored-by: philipp <descpl@yahoo.de>
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.

None yet

2 participants