Skip to content

Commit

Permalink
Merge #683
Browse files Browse the repository at this point in the history
683: Fix #657 r=jswrenn a=Easyoakland

This fix seemed very simple. Maybe I'm missing something?
Fixes #657.

Co-authored-by: Easyoakland <97992568+Easyoakland@users.noreply.github.com>
  • Loading branch information
bors[bot] and Easyoakland committed Jun 14, 2023
2 parents 878e662 + d608283 commit c17ef69
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/groupbylazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ impl<A, K, F: ?Sized> KeyFunction<A> for F


/// `ChunkIndex` acts like the grouping key function for `IntoChunks`
#[derive(Debug)]
#[derive(Debug, Clone)]
struct ChunkIndex {
size: usize,
index: usize,
Expand Down Expand Up @@ -50,7 +50,7 @@ impl<A> KeyFunction<A> for ChunkIndex {
}
}


#[derive(Clone)]
struct GroupInner<K, I, F>
where I: Iterator
{
Expand Down Expand Up @@ -471,6 +471,13 @@ pub struct IntoChunks<I>
index: Cell<usize>,
}

impl<I> Clone for IntoChunks<I>
where I: Clone + Iterator,
I::Item: Clone,
{
clone_fields!(inner, index);
}


impl<I> IntoChunks<I>
where I: Iterator,
Expand Down Expand Up @@ -507,6 +514,7 @@ impl<'a, I> IntoIterator for &'a IntoChunks<I>
///
/// See [`.chunks()`](crate::Itertools::chunks) for more information.
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
#[derive(Clone)]
pub struct Chunks<'a, I: 'a>
where I: Iterator,
I::Item: 'a,
Expand Down
11 changes: 11 additions & 0 deletions tests/quick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,17 @@ quickcheck! {
}
}

quickcheck! {
fn chunk_clone_equal(a: Vec<u8>, size: u8) -> () {
let mut size = size;
if size == 0 {
size += 1;
}
let it = a.chunks(size as usize);
itertools::assert_equal(it.clone(), it);
}
}

quickcheck! {
fn equal_chunks_lazy(a: Vec<u8>, size: u8) -> bool {
let mut size = size;
Expand Down

0 comments on commit c17ef69

Please sign in to comment.