Skip to content

Commit d0479b0

Browse files
ronnodasphimuemue
authored andcommitted
"nitpicks"
1 parent 35c78ce commit d0479b0

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

src/combinations.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ pub trait PoolIndex<T>: BorrowMut<[usize]> {
4646
where
4747
T: Clone;
4848

49-
#[inline]
5049
fn len(&self) -> usize {
5150
self.borrow().len()
5251
}
@@ -72,10 +71,6 @@ impl<T, const K: usize> PoolIndex<T> for [usize; K] {
7271
{
7372
pool.get_array(*self)
7473
}
75-
76-
fn len(&self) -> usize {
77-
K
78-
}
7974
}
8075

8176
impl<I, Idx> Clone for CombinationsGeneric<I, Idx>
@@ -132,10 +127,8 @@ impl<I: Iterator, Idx: PoolIndex<I::Item>> CombinationsGeneric<I, Idx> {
132127
pool,
133128
first,
134129
} = self;
135-
{
136-
let n = pool.count();
137-
(n, remaining_for(n, first, indices.borrow()).unwrap())
138-
}
130+
let n = pool.count();
131+
(n, remaining_for(n, first, indices.borrow()).unwrap())
139132
}
140133

141134
/// Initialises the iterator by filling a buffer with elements from the
@@ -189,7 +182,7 @@ impl<I: Iterator, Idx: PoolIndex<I::Item>> CombinationsGeneric<I, Idx> {
189182
}
190183

191184
/// Returns the n-th item or the number of successful steps.
192-
pub(crate) fn try_nth(&mut self, n: usize) -> Result<Idx::Item, usize>
185+
pub(crate) fn try_nth(&mut self, n: usize) -> Result<<Self as Iterator>::Item, usize>
193186
where
194187
I: Iterator,
195188
I::Item: Clone,
@@ -281,7 +274,7 @@ impl<I: Iterator> Combinations<I> {
281274
}
282275

283276
/// For a given size `n`, return the count of remaining combinations or None if it would overflow.
284-
pub(crate) fn remaining_for(n: usize, first: bool, indices: &[usize]) -> Option<usize> {
277+
fn remaining_for(n: usize, first: bool, indices: &[usize]) -> Option<usize> {
285278
let k = indices.len();
286279
if n < k {
287280
Some(0)

src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,8 @@ pub trait Itertools: Iterator {
16771677
/// Return an iterator adaptor that iterates over the combinations of the
16781678
/// elements from an iterator.
16791679
///
1680-
/// Iterator element can be any array of type `Self::Item`.
1680+
/// Iterator element type is [Self::Item; K]. The iterator produces a new
1681+
/// array per iteration, and clones the iterator elements.
16811682
///
16821683
/// # Guarantees
16831684
///

0 commit comments

Comments
 (0)