From b93376f46413b78b94d90aa86278f46c4aafe1fb Mon Sep 17 00:00:00 2001 From: nanoqsh Date: Sun, 10 Nov 2024 11:17:05 +0500 Subject: [PATCH] docs: document `map_while` is not fused --- src/stream.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/stream.rs b/src/stream.rs index 00f6d47..3212d42 100644 --- a/src/stream.rs +++ b/src/stream.rs @@ -1139,6 +1139,10 @@ pub trait StreamExt: Stream { /// Maps items while `predicate` returns [`Some`]. /// + /// This stream is not fused. After the predicate returns [`None`] the stream still + /// contains remaining items that can be obtained by subsequent `next` calls. + /// You can [`fuse`](StreamExt::fuse) the stream if this behavior is undesirable. + /// /// # Examples /// /// ``` @@ -1151,6 +1155,10 @@ pub trait StreamExt: Stream { /// assert_eq!(s.next().await, Some(0)); /// assert_eq!(s.next().await, Some(1)); /// assert_eq!(s.next().await, None); + /// + /// // Continue to iterate the stream. + /// assert_eq!(s.next().await, Some(2)); + /// assert_eq!(s.next().await, None); /// # }); /// ``` fn map_while(self, predicate: P) -> MapWhile