@@ -87,10 +87,14 @@ cfg_if! {
87
87
88
88
cfg_if ! {
89
89
if #[ cfg( any( feature = "unstable" , feature = "docs" ) ) ] {
90
+ mod merge;
91
+
90
92
use std:: pin:: Pin ;
91
93
92
94
use crate :: future:: Future ;
93
95
use crate :: stream:: FromStream ;
96
+
97
+ pub use merge:: Merge ;
94
98
}
95
99
}
96
100
@@ -1147,6 +1151,42 @@ extension_trait! {
1147
1151
{
1148
1152
FromStream :: from_stream( self )
1149
1153
}
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
+ }
1150
1190
}
1151
1191
1152
1192
impl <S : Stream + Unpin + ?Sized > Stream for Box <S > {
0 commit comments