@@ -34,6 +34,7 @@ mod for_each;
34
34
mod fuse;
35
35
mod inspect;
36
36
mod map;
37
+ mod merge;
37
38
mod min_by;
38
39
mod next;
39
40
mod nth;
@@ -91,6 +92,8 @@ cfg_if! {
91
92
92
93
use crate :: future:: Future ;
93
94
use crate :: stream:: FromStream ;
95
+
96
+ pub use merge:: Merge ;
94
97
}
95
98
}
96
99
@@ -1147,6 +1150,41 @@ extension_trait! {
1147
1150
{
1148
1151
FromStream :: from_stream( self )
1149
1152
}
1153
+
1154
+ #[ doc = r#"
1155
+ Combines multiple streams into a single stream of all their outputs.
1156
+
1157
+ This macro is only usable inside of async functions, closures, and blocks.
1158
+
1159
+ # Examples
1160
+
1161
+ ```
1162
+ # async_std::task::block_on(async {
1163
+ use async_std::prelude::*;
1164
+ use async_std::stream;
1165
+
1166
+ let a = stream::once(1u8);
1167
+ let b = stream::once(2u8);
1168
+ let c = stream::once(3u8);
1169
+
1170
+ let mut s = a.merge(b).merge(c);
1171
+
1172
+ assert_eq!(s.next().await, Some(1u8));
1173
+ assert_eq!(s.next().await, Some(2u8));
1174
+ assert_eq!(s.next().await, Some(3u8));
1175
+ assert_eq!(s.next().await, None);
1176
+ # });
1177
+ ```
1178
+ "# ]
1179
+ #[ cfg( any( feature = "unstable" , feature = "docs" ) ) ]
1180
+ #[ cfg_attr( feature = "docs" , doc( cfg( unstable) ) ) ]
1181
+ fn merge<U >( self , other: U ) -> Merge <Self , U >
1182
+ where
1183
+ Self : Sized ,
1184
+ U : Stream <Item = Self :: Item > + Sized ,
1185
+ {
1186
+ Merge :: new( self , other)
1187
+ }
1150
1188
}
1151
1189
1152
1190
impl <S : Stream + Unpin + ?Sized > Stream for Box <S > {
0 commit comments