diff --git a/src/path/pathbuf.rs b/src/path/pathbuf.rs index 808acb2e..e684df89 100644 --- a/src/path/pathbuf.rs +++ b/src/path/pathbuf.rs @@ -327,6 +327,8 @@ impl> stream::Extend

for PathBuf { let stream = stream.into_stream(); Box::pin(async move { + pin_utils::pin_mut!(stream); + while let Some(item) = stream.next().await { self.push(item.as_ref()); } diff --git a/src/stream/from_fn.rs b/src/stream/from_fn.rs index 3ace6583..8067176e 100644 --- a/src/stream/from_fn.rs +++ b/src/stream/from_fn.rs @@ -30,7 +30,7 @@ impl Unpin for FromFn {} /// use async_std::stream; /// /// let mut count = 0u8; -/// let mut s = stream::from_fn(|| { +/// let s = stream::from_fn(|| { /// count += 1; /// if count > 3 { /// None @@ -39,6 +39,8 @@ impl Unpin for FromFn {} /// } /// }); /// +/// pin_utils::pin_mut!(s); +/// /// assert_eq!(s.next().await, Some(1)); /// assert_eq!(s.next().await, Some(2)); /// assert_eq!(s.next().await, Some(3)); diff --git a/src/stream/repeat_with.rs b/src/stream/repeat_with.rs index 954693d8..e183a77c 100644 --- a/src/stream/repeat_with.rs +++ b/src/stream/repeat_with.rs @@ -28,7 +28,9 @@ impl Unpin for RepeatWith {} /// use async_std::prelude::*; /// use async_std::stream; /// -/// let mut s = stream::repeat_with(|| 1); +/// let s = stream::repeat_with(|| 1); +/// +/// pin_utils::pin_mut!(s); /// /// assert_eq!(s.next().await, Some(1)); /// assert_eq!(s.next().await, Some(1)); diff --git a/src/string/extend.rs b/src/string/extend.rs index 43bd46d6..55bec0c5 100644 --- a/src/string/extend.rs +++ b/src/string/extend.rs @@ -13,6 +13,8 @@ impl stream::Extend for String { self.reserve(stream.size_hint().0); Box::pin(async move { + pin_utils::pin_mut!(stream); + while let Some(item) = stream.next().await { self.push(item); } @@ -28,6 +30,8 @@ impl<'b> stream::Extend<&'b char> for String { let stream = stream.into_stream(); Box::pin(async move { + pin_utils::pin_mut!(stream); + while let Some(item) = stream.next().await { self.push(*item); } @@ -43,6 +47,8 @@ impl<'b> stream::Extend<&'b str> for String { let stream = stream.into_stream(); Box::pin(async move { + pin_utils::pin_mut!(stream); + while let Some(item) = stream.next().await { self.push_str(item); } @@ -58,6 +64,8 @@ impl stream::Extend for String { let stream = stream.into_stream(); Box::pin(async move { + pin_utils::pin_mut!(stream); + while let Some(item) = stream.next().await { self.push_str(&item); } @@ -73,6 +81,8 @@ impl<'b> stream::Extend> for String { let stream = stream.into_stream(); Box::pin(async move { + pin_utils::pin_mut!(stream); + while let Some(item) = stream.next().await { self.push_str(&item); } diff --git a/src/unit/extend.rs b/src/unit/extend.rs index 5b0bc1d1..55c8e0d0 100644 --- a/src/unit/extend.rs +++ b/src/unit/extend.rs @@ -11,6 +11,8 @@ impl stream::Extend<()> for () { let stream = stream.into_stream(); Box::pin(async move { + pin_utils::pin_mut!(stream); + while let Some(_) = stream.next().await {} }) }