Skip to content

Commit

Permalink
Prefer pop over explicit is_empty
Browse files Browse the repository at this point in the history
  • Loading branch information
phimuemue committed May 6, 2020
1 parent 3ada070 commit 7baf163
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/put_back_n_impl.rs
Expand Up @@ -48,11 +48,7 @@ impl<I: Iterator> Iterator for PutBackN<I> {
type Item = I::Item;
#[inline]
fn next(&mut self) -> Option<I::Item> {
if self.top.is_empty() {
self.iter.next()
} else {
self.top.pop()
}
self.top.pop().or_else(|| self.iter.next())
}

#[inline]
Expand Down

0 comments on commit 7baf163

Please sign in to comment.