@@ -87,10 +87,14 @@ cfg_if! {
8787
8888cfg_if ! {
8989 if #[ cfg( any( feature = "unstable" , feature = "docs" ) ) ] {
90+ mod merge;
91+
9092 use std:: pin:: Pin ;
9193
9294 use crate :: future:: Future ;
9395 use crate :: stream:: FromStream ;
96+
97+ pub use merge:: Merge ;
9498 }
9599}
96100
@@ -1147,6 +1151,42 @@ extension_trait! {
11471151 {
11481152 FromStream :: from_stream( self )
11491153 }
1154+
1155+ #[ doc = r#"
1156+ Combines multiple streams into a single stream of all their outputs.
1157+
1158+ Items are yielded as soon as they're received, and the stream continues yield until both
1159+ streams have been exhausted.
1160+
1161+ # Examples
1162+
1163+ ```
1164+ # async_std::task::block_on(async {
1165+ use async_std::prelude::*;
1166+ use async_std::stream;
1167+
1168+ let a = stream::once(1u8);
1169+ let b = stream::once(2u8);
1170+ let c = stream::once(3u8);
1171+
1172+ let mut s = a.merge(b).merge(c);
1173+
1174+ assert_eq!(s.next().await, Some(1u8));
1175+ assert_eq!(s.next().await, Some(2u8));
1176+ assert_eq!(s.next().await, Some(3u8));
1177+ assert_eq!(s.next().await, None);
1178+ # });
1179+ ```
1180+ "# ]
1181+ #[ cfg( any( feature = "unstable" , feature = "docs" ) ) ]
1182+ #[ cfg_attr( feature = "docs" , doc( cfg( unstable) ) ) ]
1183+ fn merge<U >( self , other: U ) -> Merge <Self , U >
1184+ where
1185+ Self : Sized ,
1186+ U : Stream <Item = Self :: Item > + Sized ,
1187+ {
1188+ Merge :: new( self , other)
1189+ }
11501190 }
11511191
11521192 impl <S : Stream + Unpin + ?Sized > Stream for Box <S > {
0 commit comments