Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1131 +/- ##
==========================================
- Coverage 94.38% 93.77% -0.61%
==========================================
Files 48 52 +4
Lines 6665 6478 -187
==========================================
- Hits 6291 6075 -216
- Misses 374 403 +29 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| if n < k { | ||
| return 0; | ||
| } | ||
| // Same algorithm as `checked_binomial` in `src/adaptors/mod.rs`. |
There was a problem hiding this comment.
If it's the same algorithm, can't we just call checked_binomial?
There was a problem hiding this comment.
Because checked_binomial is pub(crate) inside the private adaptors module, it isn't visible to the integration test crates in tests/.
If you'd prefer to share the implementation across tests rather than keeping the local helper, I can expose it with #[doc(hidden)] pub use crate::adaptors::checked_binomial; in lib.rs and call it here as itertools::checked_binomial(n, k).unwrap_or(0). Would you like me to do that?
There was a problem hiding this comment.
If it's really supposed to be the same code. I very much prefer this.
Or, alternatively, move the tests to src. I do not even know if we have a good reason to keep them under a separate directory, especially if we have [test] within src already.
@jswrenn opinions on this?
There was a problem hiding this comment.
Addressed in e6fce47: both integration-test helpers now reuse checked_binomial through a #[doc(hidden)] re-export. All 656 integration/doc tests passed, along with the helper unit test, no_std checks, docs, and formatting. Strict Clippy reports the same four pre-existing question_mark warnings as the previous PR head.
30a5656 to
3de7650
Compare
The naive product-then-divide binomial helper overflowed usize (C(27, 7) on 32-bit, C(21, 19) even on 64-bit). Use the same overflow-safe algorithm as checked_binomial.
e6fce47 to
7ed4bbf
Compare
|
Rebased on current master and addressed the four On 7ed4bbf, all four CI Clippy feature configurations pass with The new CI and coverage runs require maintainer approval: https://github.com/rust-itertools/itertools/actions/runs/42362308297 and https://github.com/rust-itertools/itertools/actions/runs/42362308294 . Could these be approved? The current-head semver and coverage checks have not run yet. |
|
I took this so that we can move forward. However, I still think we should probably simplify our tests so that they are inline. Moreover, this commit revealed some |
cc52d55
Fixes #995.
The size-hint test helpers multiply before dividing to compute binomial coefficients. The intermediate product can overflow
usizeeven when the result fits:C(27, 7)on 32-bit andC(21, 19)on 64-bit.Both integration-test helpers now reuse
checked_binomialthrough a#[doc(hidden)]re-export, as requested in review. Regression coverage protects the overflow cases; genuinely unrepresentable results still fail the tests.A separate small maintenance commit replaces four equivalent early-return matches with
?in the product iterator,MultiPeek, and the two folding helpers. This resolves the current Clippyquestion_markfailures without suppressing the lint or changing iterator behavior.Validation on the updated head:
RUSTFLAGS="--deny warnings": default, no-default-features, use_alloc, and all-targets/all-features.test_std: 94 passed;quick: 158 passed; folding documentation examples: 5 passed.cargo fmt --all --checkandgit diff --checkpassed.32-bit execution, the Rust 1.63 MSRV, and Miri were not run locally. The previously reported semver check concerns the existing
EitherOrBothCopy implementation; this PR does not modify that type.