From c50677b5f900102059ce8883be365642d2b236d5 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 c8ec1414..f5aa4630 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 cd99d77c..4541b6e3 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 ///