2424mod all;
2525mod any;
2626mod chain;
27+ mod cloned;
2728mod cmp;
2829mod copied;
2930mod enumerate;
@@ -91,6 +92,7 @@ use try_fold::TryFoldFuture;
9192use try_for_each:: TryForEachFuture ;
9293
9394pub use chain:: Chain ;
95+ pub use cloned:: Cloned ;
9496pub use copied:: Copied ;
9597pub use filter:: Filter ;
9698pub use fuse:: Fuse ;
@@ -373,6 +375,40 @@ extension_trait! {
373375 Chain :: new( self , other)
374376 }
375377
378+ #[ doc = r#"
379+ Creates an stream which copies all of its elements.
380+
381+ # Examples
382+
383+ Basic usage:
384+
385+ ```
386+ # fn main() { async_std::task::block_on(async {
387+ #
388+ use async_std::prelude::*;
389+ use std::collections::VecDeque;
390+
391+ let v: VecDeque<_> = vec![&1, &2, &3].into_iter().collect();
392+
393+ let mut v_cloned = v.cloned();
394+
395+ assert_eq!(v_cloned.next().await, Some(1));
396+ assert_eq!(v_cloned.next().await, Some(2));
397+ assert_eq!(v_cloned.next().await, Some(3));
398+ assert_eq!(v_cloned.next().await, None);
399+
400+ #
401+ # }) }
402+ ```
403+ "# ]
404+ fn cloned<' a, T >( self ) -> Cloned <Self >
405+ where
406+ Self : Sized + Stream <Item = & ' a T >,
407+ T : ' a + Clone ,
408+ {
409+ Cloned :: new( self )
410+ }
411+
376412
377413 #[ doc = r#"
378414 Creates an stream which copies all of its elements.
@@ -395,7 +431,6 @@ extension_trait! {
395431 assert_eq!(v_copied.next().await, Some(2));
396432 assert_eq!(v_copied.next().await, Some(3));
397433 assert_eq!(v_copied.next().await, None);
398-
399434
400435 #
401436 # }) }
0 commit comments