Skip to content

Commit 85a84bd

Browse files
committed
Rename PoolIndex to ArrayOrVecHelper
1 parent 79f52b2 commit 85a84bd

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

src/combinations.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use core::array;
22
use std::fmt;
33
use std::iter::FusedIterator;
44

5-
use super::lazy_buffer::{LazyBuffer, PoolIndex};
5+
use super::lazy_buffer::{LazyBuffer, ArrayOrVecHelper};
66
use alloc::vec::Vec;
77

88
use crate::adaptors::checked_binomial;
@@ -57,7 +57,7 @@ where
5757
debug_fmt_fields!(Combinations, indices, pool, first);
5858
}
5959

60-
impl<I: Iterator, Idx: PoolIndex> CombinationsGeneric<I, Idx> {
60+
impl<I: Iterator, Idx: ArrayOrVecHelper> CombinationsGeneric<I, Idx> {
6161
/// Constructor with arguments the inner iterator and the initial state for the indices.
6262
fn new(iter: I, indices: Idx) -> Self {
6363
Self {
@@ -174,7 +174,7 @@ impl<I, Idx> Iterator for CombinationsGeneric<I, Idx>
174174
where
175175
I: Iterator,
176176
I::Item: Clone,
177-
Idx: PoolIndex,
177+
Idx: ArrayOrVecHelper,
178178
{
179179
type Item = Idx::Item<I::Item>;
180180
fn next(&mut self) -> Option<Self::Item> {
@@ -212,7 +212,7 @@ impl<I, Idx> FusedIterator for CombinationsGeneric<I, Idx>
212212
where
213213
I: Iterator,
214214
I::Item: Clone,
215-
Idx: PoolIndex,
215+
Idx: ArrayOrVecHelper,
216216
{
217217
}
218218

src/lazy_buffer.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl MaybeConstUsize for usize {
100100

101101
/// A type holding indices of elements in a pool or buffer of items from an inner iterator
102102
/// and used to pick out different combinations in a generic way.
103-
pub trait PoolIndex: BorrowMut<[usize]> {
103+
pub trait ArrayOrVecHelper: BorrowMut<[usize]> {
104104
type Item<T>;
105105
type Length: MaybeConstUsize;
106106

@@ -113,7 +113,7 @@ pub trait PoolIndex: BorrowMut<[usize]> {
113113
fn len(&self) -> Self::Length;
114114
}
115115

116-
impl PoolIndex for Vec<usize> {
116+
impl ArrayOrVecHelper for Vec<usize> {
117117
type Item<T> = Vec<T>;
118118
type Length = usize;
119119

@@ -133,7 +133,7 @@ impl PoolIndex for Vec<usize> {
133133
}
134134
}
135135

136-
impl<const K: usize> PoolIndex for [usize; K] {
136+
impl<const K: usize> ArrayOrVecHelper for [usize; K] {
137137
type Item<T> = [T; K];
138138
type Length = ConstUsize<K>;
139139

src/permutations.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ use alloc::vec::Vec;
33
use std::fmt;
44
use std::iter::FusedIterator;
55

6-
use super::lazy_buffer::{LazyBuffer, MaybeConstUsize as _, PoolIndex};
6+
use super::lazy_buffer::{ArrayOrVecHelper, LazyBuffer, MaybeConstUsize as _};
77
use crate::size_hint::{self, SizeHint};
88

99
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
10-
pub struct PermutationsGeneric<I: Iterator, Idx: PoolIndex> {
10+
pub struct PermutationsGeneric<I: Iterator, Idx: ArrayOrVecHelper> {
1111
vals: LazyBuffer<I>,
1212
state: PermutationState<Idx>,
1313
}
@@ -23,13 +23,13 @@ impl<I, Idx> Clone for PermutationsGeneric<I, Idx>
2323
where
2424
I: Clone + Iterator,
2525
I::Item: Clone,
26-
Idx: Clone + PoolIndex,
26+
Idx: Clone + ArrayOrVecHelper,
2727
{
2828
clone_fields!(vals, state);
2929
}
3030

3131
#[derive(Clone, Debug)]
32-
enum PermutationState<Idx: PoolIndex> {
32+
enum PermutationState<Idx: ArrayOrVecHelper> {
3333
/// No permutation generated yet.
3434
Start { k: Idx::Length },
3535
/// Values from the iterator are not fully loaded yet so `n` is still unknown.
@@ -44,7 +44,7 @@ enum PermutationState<Idx: PoolIndex> {
4444
End,
4545
}
4646

47-
impl<I, Idx: PoolIndex> fmt::Debug for PermutationsGeneric<I, Idx>
47+
impl<I, Idx: ArrayOrVecHelper> fmt::Debug for PermutationsGeneric<I, Idx>
4848
where
4949
I: Iterator + fmt::Debug,
5050
I::Item: fmt::Debug,
@@ -60,7 +60,7 @@ pub fn permutations<I: Iterator>(iter: I, k: usize) -> Permutations<I> {
6060
}
6161
}
6262

63-
impl<I, Idx: PoolIndex> Iterator for PermutationsGeneric<I, Idx>
63+
impl<I, Idx: ArrayOrVecHelper> Iterator for PermutationsGeneric<I, Idx>
6464
where
6565
I: Iterator,
6666
I::Item: Clone,
@@ -140,7 +140,7 @@ where
140140
}
141141
}
142142

143-
impl<I, Idx: PoolIndex> FusedIterator for PermutationsGeneric<I, Idx>
143+
impl<I, Idx: ArrayOrVecHelper> FusedIterator for PermutationsGeneric<I, Idx>
144144
where
145145
I: Iterator,
146146
I::Item: Clone,
@@ -165,7 +165,7 @@ fn advance(indices: &mut [usize], cycles: &mut [usize]) -> bool {
165165
true
166166
}
167167

168-
impl<Idx: PoolIndex> PermutationState<Idx> {
168+
impl<Idx: ArrayOrVecHelper> PermutationState<Idx> {
169169
fn size_hint_for(&self, n: usize) -> SizeHint {
170170
// At the beginning, there are `n!/(n-k)!` items to come.
171171
let at_start = |n, k: Idx::Length| {

0 commit comments

Comments
 (0)