Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Ockajak committed Jul 13, 2024
1 parent c521925 commit f81d23c
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/extensions/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,19 +245,17 @@ pub trait Sequence<Item> {
let mut chunk_empty = true;
unfold(iterator.next(), |previous| {
let chunk: Self = unfold(false, |split| {
if *split {
return None;
if !*split {
if let Some(prev) = previous.take() {
if let Some(item) = iterator.next() {
*split = predicate(&prev, &item);
*previous = Some(item);
}
chunk_empty = false;
return Some(prev);
};
};
if let Some(prev) = previous.take() {
if let Some(item) = iterator.next() {
*split = predicate(&prev, &item);
*previous = Some(item);
}
chunk_empty = false;
Some(prev)
} else {
None
}
None
})
.collect();
if chunk_empty {
Expand Down

0 comments on commit f81d23c

Please sign in to comment.