Skip to content

Commit 532758a

Browse files
committed
rename to arrays
Iterator::array_chunks exists on nightly and it's better to avoid the name collision especially if and when that's stabilized
1 parent 1bb3739 commit 532758a

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

src/array_chunks.rs renamed to src/arrays.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ use crate::next_array::ArrayBuilder;
66
///
77
/// See [`.next_array()`](crate::Itertools::next_array) for details.
88
#[derive(Debug, Clone)]
9-
pub struct ArrayChunks<I: Iterator, const N: usize> {
9+
pub struct Arrays<I: Iterator, const N: usize> {
1010
iter: I,
1111
partial: Vec<I::Item>,
1212
}
1313

14-
impl<I: Iterator, const N: usize> ArrayChunks<I, N> {
14+
impl<I: Iterator, const N: usize> Arrays<I, N> {
1515
pub(crate) fn new(iter: I) -> Self {
1616
const {
1717
assert!(N > 0);
@@ -36,13 +36,13 @@ impl<I: Iterator, const N: usize> ArrayChunks<I, N> {
3636
/// ```
3737
/// use itertools::Itertools;
3838
///
39-
/// let mut it = (1..9).array_chunks();
39+
/// let mut it = (1..9).arrays();
4040
/// assert_eq!(Some([1, 2, 3]), it.next());
4141
/// assert_eq!(Some([4, 5, 6]), it.next());
4242
/// assert_eq!(None, it.next());
4343
/// itertools::assert_equal(it.remainder(), [7,8]);
4444
///
45-
/// let mut it = (1..9).array_chunks();
45+
/// let mut it = (1..9).arrays();
4646
/// assert_eq!(Some([1, 2, 3]), it.next());
4747
/// itertools::assert_equal(it.remainder(), 4..9);
4848
/// ```
@@ -51,7 +51,7 @@ impl<I: Iterator, const N: usize> ArrayChunks<I, N> {
5151
}
5252
}
5353

54-
impl<I: Iterator, const N: usize> Iterator for ArrayChunks<I, N> {
54+
impl<I: Iterator, const N: usize> Iterator for Arrays<I, N> {
5555
type Item = [I::Item; N];
5656

5757
fn next(&mut self) -> Option<Self::Item> {
@@ -84,7 +84,7 @@ impl<I: Iterator, const N: usize> Iterator for ArrayChunks<I, N> {
8484
}
8585
}
8686

87-
impl<I: ExactSizeIterator, const N: usize> ExactSizeIterator for ArrayChunks<I, N> {}
87+
impl<I: ExactSizeIterator, const N: usize> ExactSizeIterator for Arrays<I, N> {}
8888

8989
#[cfg(test)]
9090
mod tests {

src/lib.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ pub mod structs {
9797
TakeWhileRef, TupleCombinations, Update, WhileSome,
9898
};
9999
#[cfg(feature = "use_alloc")]
100-
pub use crate::array_chunks::ArrayChunks;
100+
pub use crate::arrays::Arrays;
101101
#[cfg(feature = "use_alloc")]
102102
pub use crate::combinations::{ArrayCombinations, Combinations};
103103
#[cfg(feature = "use_alloc")]
@@ -174,7 +174,7 @@ pub use crate::with_position::Position;
174174
pub use crate::ziptuple::multizip;
175175
mod adaptors;
176176
#[cfg(feature = "use_alloc")]
177-
mod array_chunks;
177+
mod arrays;
178178
mod either_or_both;
179179
pub use crate::either_or_both::EitherOrBoth;
180180
#[doc(hidden)]
@@ -757,41 +757,41 @@ pub trait Itertools: Iterator {
757757
/// ```rust
758758
/// use itertools::Itertools;
759759
/// let mut v = Vec::new();
760-
/// for [a, b] in (1..5).array_chunks() {
760+
/// for [a, b] in (1..5).arrays() {
761761
/// v.push([a, b]);
762762
/// }
763763
/// assert_eq!(v, vec![[1, 2], [3, 4]]);
764764
///
765-
/// let mut it = (1..9).array_chunks();
765+
/// let mut it = (1..9).arrays();
766766
/// assert_eq!(Some([1, 2, 3]), it.next());
767767
/// assert_eq!(Some([4, 5, 6]), it.next());
768768
/// assert_eq!(None, it.next());
769769
/// itertools::assert_equal(it.remainder(), [7,8]);
770770
///
771771
/// // this requires a type hint
772-
/// let it = (1..7).array_chunks::<3>();
772+
/// let it = (1..7).arrays::<3>();
773773
/// itertools::assert_equal(it, vec![[1, 2, 3], [4, 5, 6]]);
774774
///
775775
/// // you can also specify the complete type
776-
/// use itertools::ArrayChunks;
776+
/// use itertools::Arrays;
777777
/// use std::ops::Range;
778778
///
779-
/// let it: ArrayChunks<Range<u32>, 3> = (1..7).array_chunks();
779+
/// let it: Arrays<Range<u32>, 3> = (1..7).arrays();
780780
/// itertools::assert_equal(it, vec![[1, 2, 3], [4, 5, 6]]);
781781
/// ```
782782
///
783783
/// ```compile_fail
784784
/// use itertools::Itertools;
785785
///
786-
/// let mut it = (1..5).array_chunks::<0>();
786+
/// let mut it = (1..5).arrays::<0>();
787787
/// assert_eq!(Some([]), it.next());
788788
/// ```
789789
#[cfg(feature = "use_alloc")]
790-
fn array_chunks<const N: usize>(self) -> ArrayChunks<Self, N>
790+
fn arrays<const N: usize>(self) -> Arrays<Self, N>
791791
where
792792
Self: Sized,
793793
{
794-
ArrayChunks::new(self)
794+
Arrays::new(self)
795795
}
796796

797797
/// Return an iterator over all contiguous windows producing tuples of

0 commit comments

Comments
 (0)