From c7bf86a716dca5475310fa3beede5e032768de03 Mon Sep 17 00:00:00 2001 From: aobatact Date: Fri, 11 Feb 2022 11:36:43 +0900 Subject: [PATCH] Fix remove use of fuse at tuple_windows --- src/tuple_impl.rs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/tuple_impl.rs b/src/tuple_impl.rs index c19d1798e..6ccbdbacf 100644 --- a/src/tuple_impl.rs +++ b/src/tuple_impl.rs @@ -139,7 +139,7 @@ pub struct TupleWindows where I: Iterator, T: HomogeneousTuple { - iter: Fuse, + iter: I, last: Option, } @@ -151,7 +151,7 @@ pub fn tuple_windows(iter: I) -> TupleWindows { TupleWindows { last : None, - iter : iter.fuse(), + iter, } } @@ -166,25 +166,24 @@ impl Iterator for TupleWindows 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 FusedIterator for TupleWindows - where I: Iterator, + where I: FusedIterator, T: HomogeneousTuple + Clone, T::Item: Clone {}