Skip to content

Commit

Permalink
Merge #548
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bors[bot] and aobatact committed Jun 9, 2021
2 parents e1f24ba + 4f4230f commit 24f40bd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/adaptors/mod.rs
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
@@ -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
@@ -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
{}

0 comments on commit 24f40bd

Please sign in to comment.