Skip to content

Commit 21b3b27

Browse files
committed
Mention FusedIterator case in Iterator::fuse doc
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).
1 parent 9a35232 commit 21b3b27

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

library/core/src/iter/traits/iterator.rs

+5
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,12 @@ pub trait Iterator {
14951495
/// [`Some(T)`] again. `fuse()` adapts an iterator, ensuring that after a
14961496
/// [`None`] is given, it will always return [`None`] forever.
14971497
///
1498+
/// Note that the [`Fuse`] wrapper is a no-op on iterators that implement
1499+
/// the [`FusedIterator`] trait. `fuse()` may therefore behave incorrectly
1500+
/// if the [`FusedIterator`] trait is improperly implemented.
1501+
///
14981502
/// [`Some(T)`]: Some
1503+
/// [`FusedIterator`]: crate::iter::FusedIterator
14991504
///
15001505
/// # Examples
15011506
///

0 commit comments

Comments
 (0)