Skip to content

Commit 24f40bd

Browse files
bors[bot]aobatact
andauthored
Merge #548
548: Add FusedIterator for which it is commented fused. r=jswrenn a=aobatact `Interleave`, `IntersperseWith`, and `ZipLongest` are said to be fused in doc comment, but it wasn't marked as `FusedIterator`. Co-authored-by: aobatact <aobatact144@gmail.com>
2 parents e1f24ba + 4f4230f commit 24f40bd

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

src/adaptors/mod.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)