Add array_combinations_with_replacement#1033
Add array_combinations_with_replacement#1033phimuemue merged 8 commits intorust-itertools:masterfrom
array_combinations_with_replacement#1033Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1033 +/- ##
==========================================
- Coverage 94.38% 94.28% -0.11%
==========================================
Files 48 50 +2
Lines 6665 6226 -439
==========================================
- Hits 6291 5870 -421
+ Misses 374 356 -18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| if self.first { | ||
| // In empty edge cases, stop iterating immediately | ||
| if !(self.indices.is_empty() || self.pool.get_next()) { | ||
| if !(core::borrow::Borrow::<[usize]>::borrow(&self.indices).is_empty() |
There was a problem hiding this comment.
Can't we write self.indices.borrow()?
There was a problem hiding this comment.
Weird, that work, when I originally tried doing that I got an error, but now it works.
|
|
||
| /// Iterator for `Box<[I]>` valued combinations_with_replacement returned by [`.combinations_with_replacement()`](crate::Itertools::combinations_with_replacement) | ||
| pub type CombinationsWithReplacement<I> = CombinationsWithReplacementGeneric<I, Box<[usize]>>; | ||
| /// Iterator for const generic combinations_with_replacement returned by [`.array_combinations_with_replacement()`](crate::Itertools::array_combinations_with_replacement) |
There was a problem hiding this comment.
Non-markdown expert here: Is the (crate::Itertools::array_combinations_with_replacement) required?
There was a problem hiding this comment.
I don't know I just copied and modified the doc comment from two lines above.
The whole combinations_with_replacement file seems to feature gated under Edit: |
|
I added test for |
(and its dependencies)
There was a problem hiding this comment.
Thank you. Could you fix so that CI runs through?
Can you limit the cfgs to where they are necessary please?
And by the way: Thanks for splitting up the PR into nicely diffable chunks, and for just amending instead of force-pushing and overwriting old commits.
| } | ||
| } | ||
| impl<T> PoolIndex<T> for Box<[usize]> { | ||
| type Item = Vec<T>; |
There was a problem hiding this comment.
We can think about returning Box<[T]> later, but since we'd probably construct it via a Vec, Vec is fine.
There was a problem hiding this comment.
I just what did not change that, as that was the way it was before.
|
Maybe we should remove the |
`combinations_with_replacements` as they are done at a module level right now.
f6e349a
This PR adds a new method for iterators called
array_combinations_with_replacementwhich is similar tocombinations_with_replacement, except for that it uses const generics and arrays.This is similar to
array_combinationsandcombinations.I also generalized the underlying
CombinationsWithReplacementtype similar to how it is done withCombinations.This closes #1025.