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 ;
@@ -379,6 +381,40 @@ extension_trait! {
379381 Chain :: new( self , other)
380382 }
381383
384+ #[ doc = r#"
385+ Creates an stream which copies all of its elements.
386+
387+ # Examples
388+
389+ Basic usage:
390+
391+ ```
392+ # fn main() { async_std::task::block_on(async {
393+ #
394+ use async_std::prelude::*;
395+ use async_std::stream;
396+
397+ let v = stream::from_iter(vec![&1, &2, &3]);
398+
399+ let mut v_cloned = v.cloned();
400+
401+ assert_eq!(v_cloned.next().await, Some(1));
402+ assert_eq!(v_cloned.next().await, Some(2));
403+ assert_eq!(v_cloned.next().await, Some(3));
404+ assert_eq!(v_cloned.next().await, None);
405+
406+ #
407+ # }) }
408+ ```
409+ "# ]
410+ fn cloned<' a, T >( self ) -> Cloned <Self >
411+ where
412+ Self : Sized + Stream <Item = & ' a T >,
413+ T : ' a + Clone ,
414+ {
415+ Cloned :: new( self )
416+ }
417+
382418
383419 #[ doc = r#"
384420 Creates an stream which copies all of its elements.
@@ -394,8 +430,6 @@ extension_trait! {
394430 use async_std::stream;
395431
396432 let s = stream::from_iter(vec![&1, &2, &3]);
397- let second = stream::from_iter(vec![2, 3]);
398-
399433 let mut s_copied = s.copied();
400434
401435 assert_eq!(s_copied.next().await, Some(1));
0 commit comments