mirror of
https://github.com/async-rs/async-std.git
synced 2025-01-30 01:05:31 +00:00
Improved the code with some minor changes
This commit is contained in:
parent
f6829859fe
commit
72ca2c1a24
2 changed files with 6 additions and 11 deletions
|
@ -62,12 +62,11 @@ where
|
|||
S: Stream<Item = I>,
|
||||
{
|
||||
match first.poll_next(cx) {
|
||||
Poll::Ready(Some(item)) => Poll::Ready(Some(item)),
|
||||
Poll::Ready(None) => second.poll_next(cx),
|
||||
Poll::Ready(item) => Poll::Ready(item),
|
||||
Poll::Pending => match second.poll_next(cx) {
|
||||
Poll::Ready(Some(item)) => Poll::Ready(Some(item)),
|
||||
Poll::Ready(None) => Poll::Pending,
|
||||
Poll::Pending => Poll::Pending,
|
||||
Poll::Ready(None) | Poll::Pending => Poll::Pending,
|
||||
Poll::Ready(item) => Poll::Ready(item),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1663,18 +1663,14 @@ extension_trait! {
|
|||
```
|
||||
# async_std::task::block_on(async {
|
||||
use async_std::prelude::*;
|
||||
use async_std::stream;
|
||||
use async_std::stream::{self, FromStream};
|
||||
|
||||
let a = stream::once(1u8);
|
||||
let b = stream::once(2u8);
|
||||
let c = stream::once(3u8);
|
||||
|
||||
let mut s = a.merge(b).merge(c);
|
||||
let mut lst = Vec::new();
|
||||
|
||||
while let Some(n) = s.next().await {
|
||||
lst.push(n)
|
||||
}
|
||||
let s = a.merge(b).merge(c);
|
||||
let mut lst = Vec::from_stream(s).await;
|
||||
|
||||
lst.sort_unstable();
|
||||
assert_eq!(&lst, &[1u8, 2u8, 3u8]);
|
||||
|
|
Loading…
Reference in a new issue