Skip to content

Add FusedIterator for which it is commented fused. #548

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/adaptors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub use self::map::MapResults;
pub use self::multi_product::*;

use std::fmt;
use std::iter::{Fuse, Peekable, FromIterator};
use std::iter::{Fuse, Peekable, FromIterator, FusedIterator};
use std::marker::PhantomData;
use crate::size_hint;

Expand Down Expand Up @@ -75,6 +75,11 @@ impl<I, J> Iterator for Interleave<I, J>
}
}

impl<I, J> FusedIterator for Interleave<I, J>
where I: Iterator,
J: Iterator<Item = I::Item>
{}

/// An iterator adaptor that alternates elements from the two iterators until
/// one of them runs out.
///
Expand Down
7 changes: 6 additions & 1 deletion src/intersperse.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::iter::Fuse;
use std::iter::{Fuse, FusedIterator};
use super::size_hint;

pub trait IntersperseElement<Item> {
Expand Down Expand Up @@ -112,3 +112,8 @@ impl<I, ElemF> Iterator for IntersperseWith<I, ElemF>
})
}
}

impl<I, ElemF> FusedIterator for IntersperseWith<I, ElemF>
where I: Iterator,
ElemF: IntersperseElement<I::Item>
{}
7 changes: 6 additions & 1 deletion src/zip_longest.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::cmp::Ordering::{Equal, Greater, Less};
use super::size_hint;
use std::iter::Fuse;
use std::iter::{Fuse, FusedIterator};

use crate::either_or_both::EitherOrBoth;

Expand Down Expand Up @@ -76,3 +76,8 @@ impl<T, U> ExactSizeIterator for ZipLongest<T, U>
where T: ExactSizeIterator,
U: ExactSizeIterator
{}

impl<T, U> FusedIterator for ZipLongest<T, U>
where T: Iterator,
U: Iterator
{}