Skip to content

Commit

Permalink
Mention FusedIterator case in Iterator::fuse doc
Browse files Browse the repository at this point in the history
Using `fuse` on an iterator that incorrectly implements
`FusedIterator` does not fuse the iterator. This commit adds a
note about this in the documentation of this method to increase
awareness about this potential issue (esp. when relying on fuse
in unsafe code).
  • Loading branch information
amorison committed Apr 23, 2021
1 parent 9a35232 commit 21b3b27
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/core/src/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,12 @@ pub trait Iterator {
/// [`Some(T)`] again. `fuse()` adapts an iterator, ensuring that after a
/// [`None`] is given, it will always return [`None`] forever.
///
/// Note that the [`Fuse`] wrapper is a no-op on iterators that implement
/// the [`FusedIterator`] trait. `fuse()` may therefore behave incorrectly
/// if the [`FusedIterator`] trait is improperly implemented.
///
/// [`Some(T)`]: Some
/// [`FusedIterator`]: crate::iter::FusedIterator
///
/// # Examples
///
Expand Down

0 comments on commit 21b3b27

Please sign in to comment.