From 21b3b27fe4695e13f089a75e67981478b3067a00 Mon Sep 17 00:00:00 2001 From: Adrien Morison Date: Fri, 23 Apr 2021 18:59:10 +0100 Subject: [PATCH] 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). --- library/core/src/iter/traits/iterator.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/library/core/src/iter/traits/iterator.rs b/library/core/src/iter/traits/iterator.rs index abd44b47f9886..c0cab86cf622f 100644 --- a/library/core/src/iter/traits/iterator.rs +++ b/library/core/src/iter/traits/iterator.rs @@ -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 ///