diff --git a/src/multipeek_impl.rs b/src/multipeek_impl.rs index 0b64e1d7a..99ee3953e 100644 --- a/src/multipeek_impl.rs +++ b/src/multipeek_impl.rs @@ -82,11 +82,7 @@ impl Iterator for MultiPeek fn next(&mut self) -> Option { self.index = 0; - if self.buf.is_empty() { - self.iter.next() - } else { - self.buf.pop_front() - } + self.buf.pop_front().or_else(|| self.iter.next()) } fn size_hint(&self) -> (usize, Option) { diff --git a/src/put_back_n_impl.rs b/src/put_back_n_impl.rs index dcb28946e..348c1d00e 100644 --- a/src/put_back_n_impl.rs +++ b/src/put_back_n_impl.rs @@ -48,11 +48,7 @@ impl Iterator for PutBackN { type Item = I::Item; #[inline] fn next(&mut self) -> Option { - if self.top.is_empty() { - self.iter.next() - } else { - self.top.pop() - } + self.top.pop().or_else(|| self.iter.next()) } #[inline]