diff --git a/src/stream/stream/merge.rs b/src/stream/stream/merge.rs index bdf7a29..d9d2b0a 100644 --- a/src/stream/stream/merge.rs +++ b/src/stream/stream/merge.rs @@ -62,12 +62,11 @@ where S: Stream, { 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), }, } } diff --git a/src/stream/stream/mod.rs b/src/stream/stream/mod.rs index 7c4bceb..223aea5 100644 --- a/src/stream/stream/mod.rs +++ b/src/stream/stream/mod.rs @@ -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]);