Skip to content

Improve Unique[By]/Duplicates[By] debug messages - #1121

Open
FHTMitchell wants to merge 1 commit into
rust-itertools:masterfrom
FHTMitchell:fm/unique-duplicate-debugs
Open

Improve Unique[By]/Duplicates[By] debug messages#1121
FHTMitchell wants to merge 1 commit into
rust-itertools:masterfrom
FHTMitchell:fm/unique-duplicate-debugs

Conversation

@FHTMitchell

@FHTMitchell FHTMitchell commented Aug 17, 2026

Copy link
Copy Markdown

Updates the Debug impls of Duplicates[By] and Unique[By] to be more descriptive. Hides the implementation detail that seen is a HashMap under the hood for Unique[By] and removes the meta redirect in Duplicates[By].

Open questions:

  1. Unique doesn't actually get any benefit from having an inner: UniqueBy field since it has it's own next impl. Should we just lift those fields into the struct?
  2. I renamed used to seen which feels like a more correct name, but I can revert.
  3. I made the *By structs use finish_non_exhaustive which adds a .. to the representation. That's not something anything using the macro gets but useful information I feel. Might be worth adding a .. option to the macro?
  4. Should the values in seen in Duplicates[By] become a 2-valued enum (not a bool) to make it clearer what's going on? Probably not worth it...
 // Before

  Unique { iter: UniqueBy { iter: Iter(["b", "c"]), used: {"a": ()} } }
  UniqueBy { iter: Iter(["b", "c"]), used: {1: ()} }
  DuplicatesBy { iter: Iter([3]), meta.used: {1: false, 2: true} }
  DuplicatesBy { iter: Iter([3]), meta.used: {0: true, 1: false} }

// After

  Unique { iter: Iter(["b", "c"]), seen: {"a"} }
  UniqueBy { iter: Iter(["b", "c"]), seen: {1}, .. }
  Duplicates   { iter: Iter([3]), seen: {1: false, 2: true}, pending: 1 }
  DuplicatesBy { iter: Iter([3]), seen: {0: true, 1: false}, pending: 1, .. }

@codecov

codecov Bot commented Aug 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 42.00000% with 29 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.57%. Comparing base (6814180) to head (19e625d).
⚠️ Report is 211 commits behind head on master.

Files with missing lines Patch % Lines
src/unique_impl.rs 54.54% 15 Missing ⚠️
src/duplicates_impl.rs 17.64% 14 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1121      +/-   ##
==========================================
- Coverage   94.38%   93.57%   -0.82%     
==========================================
  Files          48       52       +4     
  Lines        6665     6708      +43     
==========================================
- Hits         6291     6277      -14     
- Misses        374      431      +57     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

1 participant