mirror of
https://github.com/async-rs/async-std.git
synced 2025-01-16 10:49:55 +00:00
Cleaning up stream pinning.
This commit is contained in:
parent
f0875d2dca
commit
e442eba625
5 changed files with 20 additions and 2 deletions
|
@ -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…
Reference in a new issue