Improved the code with some minor changes

pull/503/head
razican 5 years ago
parent f6829859fe
commit 72ca2c1a24
No known key found for this signature in database
GPG Key ID: 76E895FB1EDE827C

@ -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…
Cancel
Save