Cleaning up stream pinning.

pull/520/head
Grzegorz Gierlach 5 years ago
parent f0875d2dca
commit e442eba625

@ -327,6 +327,8 @@ impl<P: AsRef<Path>> stream::Extend<P> 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());
}

@ -30,7 +30,7 @@ impl<F> Unpin for FromFn<F> {}
/// 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<F> Unpin for FromFn<F> {}
/// }
/// });
///
/// 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));

@ -28,7 +28,9 @@ impl<F> Unpin for RepeatWith<F> {}
/// 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));

@ -13,6 +13,8 @@ impl stream::Extend<char> 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<String> 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<Cow<'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);
}

@ -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 {}
})
}

Loading…
Cancel
Save