Skip to content

Commit

Permalink
"nitpicks"
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnodas committed Sep 11, 2024
1 parent 325d382 commit 8df4572
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
15 changes: 4 additions & 11 deletions src/combinations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ pub trait PoolIndex<T>: BorrowMut<[usize]> {
where
T: Clone;

#[inline]
fn len(&self) -> usize {
self.borrow().len()
}
Expand All @@ -72,10 +71,6 @@ impl<T, const K: usize> PoolIndex<T> for [usize; K] {
{
pool.get_array(*self)
}

fn len(&self) -> usize {
K
}
}

impl<I, Idx> Clone for CombinationsGeneric<I, Idx>
Expand Down Expand Up @@ -132,10 +127,8 @@ impl<I: Iterator, Idx: PoolIndex<I::Item>> CombinationsGeneric<I, Idx> {
pool,
first,
} = self;
{
let n = pool.count();
(n, remaining_for(n, first, indices.borrow()).unwrap())
}
let n = pool.count();
(n, remaining_for(n, first, indices.borrow()).unwrap())
}

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

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

/// For a given size `n`, return the count of remaining combinations or None if it would overflow.
pub(crate) fn remaining_for(n: usize, first: bool, indices: &[usize]) -> Option<usize> {
fn remaining_for(n: usize, first: bool, indices: &[usize]) -> Option<usize> {
let k = indices.len();
if n < k {
Some(0)
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1674,7 +1674,8 @@ pub trait Itertools: Iterator {
/// Return an iterator adaptor that iterates over the combinations of the
/// elements from an iterator.
///
/// Iterator element can be any array of type `Self::Item`.
/// Iterator element type is [Self::Item; K]. The iterator produces a new
/// array per iteration, and clones the iterator elements.
///
/// # Guarantees
///
Expand Down

0 comments on commit 8df4572

Please sign in to comment.