Skip to content

Commit b93376f

Browse files
nanoqshnotgull
authored andcommitted
docs: document map_while is not fused
1 parent 24e3424 commit b93376f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/stream.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,10 @@ pub trait StreamExt: Stream {
11391139

11401140
/// Maps items while `predicate` returns [`Some`].
11411141
///
1142+
/// This stream is not fused. After the predicate returns [`None`] the stream still
1143+
/// contains remaining items that can be obtained by subsequent `next` calls.
1144+
/// You can [`fuse`](StreamExt::fuse) the stream if this behavior is undesirable.
1145+
///
11421146
/// # Examples
11431147
///
11441148
/// ```
@@ -1151,6 +1155,10 @@ pub trait StreamExt: Stream {
11511155
/// assert_eq!(s.next().await, Some(0));
11521156
/// assert_eq!(s.next().await, Some(1));
11531157
/// assert_eq!(s.next().await, None);
1158+
///
1159+
/// // Continue to iterate the stream.
1160+
/// assert_eq!(s.next().await, Some(2));
1161+
/// assert_eq!(s.next().await, None);
11541162
/// # });
11551163
/// ```
11561164
fn map_while<B, P>(self, predicate: P) -> MapWhile<Self, P>

0 commit comments

Comments
 (0)