2323
2424mod all;
2525mod any;
26+ mod chain;
2627mod enumerate;
2728mod filter;
2829mod filter_map;
@@ -41,6 +42,7 @@ mod step_by;
4142mod take;
4243mod zip;
4344
45+ pub use chain:: Chain ;
4446pub use filter:: Filter ;
4547pub use fuse:: Fuse ;
4648pub use inspect:: Inspect ;
@@ -268,6 +270,39 @@ pub trait Stream {
268270 StepBy :: new ( self , step)
269271 }
270272
273+ /// Takes two streams and creates a new stream over both in sequence.
274+ ///
275+ /// # Examples
276+ ///
277+ /// Basic usage:
278+ ///
279+ /// ```
280+ /// # fn main() { async_std::task::block_on(async {
281+ /// #
282+ /// use async_std::prelude::*;
283+ /// use std::collections::VecDeque;
284+ ///
285+ /// let first: VecDeque<_> = vec![0u8, 1].into_iter().collect();
286+ /// let second: VecDeque<_> = vec![2, 3].into_iter().collect();
287+ /// let mut c = first.chain(second);
288+ ///
289+ /// assert_eq!(c.next().await, Some(0));
290+ /// assert_eq!(c.next().await, Some(1));
291+ /// assert_eq!(c.next().await, Some(2));
292+ /// assert_eq!(c.next().await, Some(3));
293+ /// assert_eq!(c.next().await, None);
294+ ///
295+ /// #
296+ /// # }) }
297+ /// ```
298+ fn chain < U > ( self , other : U ) -> Chain < Self , U >
299+ where
300+ Self : Sized ,
301+ U : Stream < Item = Self :: Item > + Sized ,
302+ {
303+ Chain :: new ( self , other)
304+ }
305+
271306 /// Creates a stream that gives the current element's count as well as the next value.
272307 ///
273308 /// # Overflow behaviour.
0 commit comments