Skip to content

Commit

Permalink
Fix remove use of fuse at tuple_windows
Browse files Browse the repository at this point in the history
  • Loading branch information
aobatact committed Feb 11, 2022
1 parent 8cf7b7d commit c7bf86a
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/tuple_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub struct TupleWindows<I, T>
where I: Iterator<Item = T::Item>,
T: HomogeneousTuple
{
iter: Fuse<I>,
iter: I,
last: Option<T>,
}

Expand All @@ -151,7 +151,7 @@ pub fn tuple_windows<I, T>(iter: I) -> TupleWindows<I, T>
{
TupleWindows {
last : None,
iter : iter.fuse(),
iter,
}
}

Expand All @@ -166,25 +166,24 @@ impl<I, T> Iterator for TupleWindows<I, T>
if T::num_items() == 1 {
return T::collect_from_iter_no_buf(&mut self.iter)
}
if let Some(ref mut last) = self.last {
if let Some(new) = self.iter.next() {
if let Some(new) = self.iter.next() {
if let Some(ref mut last) = self.last {
last.left_shift_push(new);
return Some(last.clone());
}
} else {
use std::iter::once;
if let Some(item) = self.iter.next() {
let iter = once(item).chain(&mut self.iter);
Some(last.clone())
} else {
use std::iter::once;
let iter = once(new).chain(&mut self.iter);
self.last = T::collect_from_iter_no_buf(iter);
return self.last.clone();
self.last.clone()
}
} else {
None
}
None
}
}

impl<I, T> FusedIterator for TupleWindows<I, T>
where I: Iterator<Item = T::Item>,
where I: FusedIterator<Item = T::Item>,
T: HomogeneousTuple + Clone,
T::Item: Clone
{}
Expand Down

0 comments on commit c7bf86a

Please sign in to comment.