Skip to content

Commit 4f4230f

Browse files
committed
Add FusedIterator for which it is commented fused.
Interleave, IntersperseWith, and ZipLongest are said to be fused, but it wasn't marked as FusedIterator.
1 parent a9e367f commit 4f4230f

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/adaptors/mod.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ pub use self::map::MapResults;
1515
pub use self::multi_product::*;
1616

1717
use std::fmt;
18-
use std::iter::{Fuse, Peekable, FromIterator};
18+
use std::iter::{Fuse, Peekable, FromIterator, FusedIterator};
1919
use std::marker::PhantomData;
2020
use crate::size_hint;
2121

@@ -75,6 +75,11 @@ impl<I, J> Iterator for Interleave<I, J>
7575
}
7676
}
7777

78+
impl<I, J> FusedIterator for Interleave<I, J>
79+
where I: Iterator,
80+
J: Iterator<Item = I::Item>
81+
{}
82+
7883
/// An iterator adaptor that alternates elements from the two iterators until
7984
/// one of them runs out.
8085
///

src/intersperse.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::iter::Fuse;
1+
use std::iter::{Fuse, FusedIterator};
22
use super::size_hint;
33

44
pub trait IntersperseElement<Item> {
@@ -112,3 +112,8 @@ impl<I, ElemF> Iterator for IntersperseWith<I, ElemF>
112112
})
113113
}
114114
}
115+
116+
impl<I, ElemF> FusedIterator for IntersperseWith<I, ElemF>
117+
where I: Iterator,
118+
ElemF: IntersperseElement<I::Item>
119+
{}

src/zip_longest.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::cmp::Ordering::{Equal, Greater, Less};
22
use super::size_hint;
3-
use std::iter::Fuse;
3+
use std::iter::{Fuse, FusedIterator};
44

55
use crate::either_or_both::EitherOrBoth;
66

@@ -76,3 +76,8 @@ impl<T, U> ExactSizeIterator for ZipLongest<T, U>
7676
where T: ExactSizeIterator,
7777
U: ExactSizeIterator
7878
{}
79+
80+
impl<T, U> FusedIterator for ZipLongest<T, U>
81+
where T: Iterator,
82+
U: Iterator
83+
{}

0 commit comments

Comments
 (0)