From 8df4572473a9436e8114cbc13ccc68d5df44cd96 Mon Sep 17 00:00:00 2001 From: Ronno Das Date: Wed, 11 Sep 2024 22:24:41 +0200 Subject: [PATCH] "nitpicks" --- src/combinations.rs | 15 ++++----------- src/lib.rs | 3 ++- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/combinations.rs b/src/combinations.rs index c8ec14142..f5aa4630e 100644 --- a/src/combinations.rs +++ b/src/combinations.rs @@ -46,7 +46,6 @@ pub trait PoolIndex: BorrowMut<[usize]> { where T: Clone; - #[inline] fn len(&self) -> usize { self.borrow().len() } @@ -72,10 +71,6 @@ impl PoolIndex for [usize; K] { { pool.get_array(*self) } - - fn len(&self) -> usize { - K - } } impl Clone for CombinationsGeneric @@ -132,10 +127,8 @@ impl> CombinationsGeneric { 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 @@ -189,7 +182,7 @@ impl> CombinationsGeneric { } /// Returns the n-th item or the number of successful steps. - pub(crate) fn try_nth(&mut self, n: usize) -> Result + pub(crate) fn try_nth(&mut self, n: usize) -> Result<::Item, usize> where I: Iterator, I::Item: Clone, @@ -281,7 +274,7 @@ impl Combinations { } /// 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 { +fn remaining_for(n: usize, first: bool, indices: &[usize]) -> Option { let k = indices.len(); if n < k { Some(0) diff --git a/src/lib.rs b/src/lib.rs index cd99d77ca..63685fc87 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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 ///