@@ -409,7 +409,7 @@ impl<R: Try> LoopState<R::Ok, R> {
409409///
410410/// [`rev`]: trait.Iterator.html#method.rev
411411/// [`Iterator`]: trait.Iterator.html
412- #[ derive( Clone , Debug ) ]
412+ #[ derive( Copy , Clone , Debug ) ]
413413#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
414414#[ stable( feature = "rust1" , since = "1.0.0" ) ]
415415pub struct Rev < T > {
@@ -506,7 +506,7 @@ unsafe impl<I> TrustedLen for Rev<I>
506506/// [`Iterator`]: trait.Iterator.html
507507#[ stable( feature = "iter_cloned" , since = "1.1.0" ) ]
508508#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
509- #[ derive( Clone , Debug ) ]
509+ #[ derive( Copy , Clone , Debug ) ]
510510pub struct Cloned < I > {
511511 it : I ,
512512}
@@ -614,7 +614,7 @@ unsafe impl<'a, I, T: 'a> TrustedLen for Cloned<I>
614614///
615615/// [`cycle`]: trait.Iterator.html#method.cycle
616616/// [`Iterator`]: trait.Iterator.html
617- #[ derive( Clone , Debug ) ]
617+ #[ derive( Copy , Clone , Debug ) ]
618618#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
619619#[ stable( feature = "rust1" , since = "1.0.0" ) ]
620620pub struct Cycle < I > {
@@ -659,7 +659,7 @@ impl<I> FusedIterator for Cycle<I> where I: Clone + Iterator {}
659659#[ unstable( feature = "iterator_step_by" ,
660660 reason = "unstable replacement of Range::step_by" ,
661661 issue = "27741" ) ]
662- #[ derive( Clone , Debug ) ]
662+ #[ derive( Copy , Clone , Debug ) ]
663663pub struct StepBy < I > {
664664 iter : I ,
665665 step : usize ,
@@ -709,7 +709,7 @@ impl<I> ExactSizeIterator for StepBy<I> where I: ExactSizeIterator {}
709709///
710710/// [`chain`]: trait.Iterator.html#method.chain
711711/// [`Iterator`]: trait.Iterator.html
712- #[ derive( Clone , Debug ) ]
712+ #[ derive( Copy , Clone , Debug ) ]
713713#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
714714#[ stable( feature = "rust1" , since = "1.0.0" ) ]
715715pub struct Chain < A , B > {
@@ -731,7 +731,7 @@ pub struct Chain<A, B> {
731731//
732732// The fourth state (neither iterator is remaining) only occurs after Chain has
733733// returned None once, so we don't need to store this state.
734- #[ derive( Clone , Debug ) ]
734+ #[ derive( Copy , Clone , Debug ) ]
735735enum ChainState {
736736 // both front and back iterator are remaining
737737 Both ,
@@ -960,7 +960,7 @@ unsafe impl<A, B> TrustedLen for Chain<A, B>
960960///
961961/// [`zip`]: trait.Iterator.html#method.zip
962962/// [`Iterator`]: trait.Iterator.html
963- #[ derive( Clone , Debug ) ]
963+ #[ derive( Copy , Clone , Debug ) ]
964964#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
965965#[ stable( feature = "rust1" , since = "1.0.0" ) ]
966966pub struct Zip < A , B > {
@@ -1227,7 +1227,7 @@ unsafe impl<A, B> TrustedLen for Zip<A, B>
12271227/// ```
12281228#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
12291229#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1230- #[ derive( Clone ) ]
1230+ #[ derive( Copy , Clone ) ]
12311231pub struct Map < I , F > {
12321232 iter : I ,
12331233 f : F ,
@@ -1338,7 +1338,7 @@ unsafe impl<B, I, F> TrustedRandomAccess for Map<I, F>
13381338/// [`Iterator`]: trait.Iterator.html
13391339#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
13401340#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1341- #[ derive( Clone ) ]
1341+ #[ derive( Copy , Clone ) ]
13421342pub struct Filter < I , P > {
13431343 iter : I ,
13441344 predicate : P ,
@@ -1470,7 +1470,7 @@ impl<I: FusedIterator, P> FusedIterator for Filter<I, P>
14701470/// [`Iterator`]: trait.Iterator.html
14711471#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
14721472#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1473- #[ derive( Clone ) ]
1473+ #[ derive( Copy , Clone ) ]
14741474pub struct FilterMap < I , F > {
14751475 iter : I ,
14761476 f : F ,
@@ -1739,7 +1739,7 @@ unsafe impl<I> TrustedLen for Enumerate<I>
17391739///
17401740/// [`peekable`]: trait.Iterator.html#method.peekable
17411741/// [`Iterator`]: trait.Iterator.html
1742- #[ derive( Clone , Debug ) ]
1742+ #[ derive( Debug ) ]
17431743#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
17441744#[ stable( feature = "rust1" , since = "1.0.0" ) ]
17451745pub struct Peekable < I : Iterator > {
@@ -1748,6 +1748,27 @@ pub struct Peekable<I: Iterator> {
17481748 peeked : Option < Option < I :: Item > > ,
17491749}
17501750
1751+ #[ stable( feature = "rust1" , since = "1.25.0" ) ]
1752+ impl < I > Copy for Peekable < I >
1753+ where
1754+ I : Iterator + Copy ,
1755+ I :: Item : Copy ,
1756+ { }
1757+
1758+ #[ stable( feature = "rust1" , since = "1.25.0" ) ]
1759+ impl < I > Clone for Peekable < I >
1760+ where
1761+ I : Iterator + Clone ,
1762+ I :: Item : Clone ,
1763+ {
1764+ fn clone ( & self ) -> Self {
1765+ Peekable {
1766+ iter : self . iter . clone ( ) ,
1767+ peeked : self . peeked . clone ( ) ,
1768+ }
1769+ }
1770+ }
1771+
17511772// Peekable must remember if a None has been seen in the `.peek()` method.
17521773// It ensures that `.peek(); .peek();` or `.peek(); .next();` only advances the
17531774// underlying iterator at most once. This does not by itself make the iterator
@@ -1906,7 +1927,7 @@ impl<I: Iterator> Peekable<I> {
19061927/// [`Iterator`]: trait.Iterator.html
19071928#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
19081929#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1909- #[ derive( Clone ) ]
1930+ #[ derive( Copy , Clone ) ]
19101931pub struct SkipWhile < I , P > {
19111932 iter : I ,
19121933 flag : bool ,
@@ -1989,7 +2010,7 @@ impl<I, P> FusedIterator for SkipWhile<I, P>
19892010/// [`Iterator`]: trait.Iterator.html
19902011#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
19912012#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1992- #[ derive( Clone ) ]
2013+ #[ derive( Copy , Clone ) ]
19932014pub struct TakeWhile < I , P > {
19942015 iter : I ,
19952016 flag : bool ,
@@ -2066,7 +2087,7 @@ impl<I, P> FusedIterator for TakeWhile<I, P>
20662087///
20672088/// [`skip`]: trait.Iterator.html#method.skip
20682089/// [`Iterator`]: trait.Iterator.html
2069- #[ derive( Clone , Debug ) ]
2090+ #[ derive( Copy , Clone , Debug ) ]
20702091#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
20712092#[ stable( feature = "rust1" , since = "1.0.0" ) ]
20722093pub struct Skip < I > {
@@ -2204,7 +2225,7 @@ impl<I> FusedIterator for Skip<I> where I: FusedIterator {}
22042225///
22052226/// [`take`]: trait.Iterator.html#method.take
22062227/// [`Iterator`]: trait.Iterator.html
2207- #[ derive( Clone , Debug ) ]
2228+ #[ derive( Copy , Clone , Debug ) ]
22082229#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
22092230#[ stable( feature = "rust1" , since = "1.0.0" ) ]
22102231pub struct Take < I > {
@@ -2287,7 +2308,7 @@ impl<I> FusedIterator for Take<I> where I: FusedIterator {}
22872308/// [`Iterator`]: trait.Iterator.html
22882309#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
22892310#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2290- #[ derive( Clone ) ]
2311+ #[ derive( Copy , Clone ) ]
22912312pub struct Scan < I , St , F > {
22922313 iter : I ,
22932314 f : F ,
@@ -2347,14 +2368,40 @@ impl<B, I, St, F> Iterator for Scan<I, St, F> where
23472368/// [`Iterator`]: trait.Iterator.html
23482369#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
23492370#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2350- #[ derive( Clone ) ]
23512371pub struct FlatMap < I , U : IntoIterator , F > {
23522372 iter : I ,
23532373 f : F ,
23542374 frontiter : Option < U :: IntoIter > ,
23552375 backiter : Option < U :: IntoIter > ,
23562376}
23572377
2378+ #[ stable( feature = "rust1" , since = "1.25.0" ) ]
2379+ impl < I , U , F > Copy for FlatMap < I , U , F >
2380+ where
2381+ I : Copy ,
2382+ F : Copy ,
2383+ U : IntoIterator ,
2384+ U :: IntoIter : Copy ,
2385+ { }
2386+
2387+ #[ stable( feature = "rust1" , since = "1.25.0" ) ]
2388+ impl < I , U , F > Clone for FlatMap < I , U , F >
2389+ where
2390+ I : Clone ,
2391+ F : Clone ,
2392+ U : IntoIterator ,
2393+ U :: IntoIter : Clone ,
2394+ {
2395+ fn clone ( & self ) -> Self {
2396+ FlatMap {
2397+ iter : self . iter . clone ( ) ,
2398+ f : self . f . clone ( ) ,
2399+ frontiter : self . frontiter . clone ( ) ,
2400+ backiter : self . backiter . clone ( ) ,
2401+ }
2402+ }
2403+ }
2404+
23582405#[ stable( feature = "core_impl_debug" , since = "1.9.0" ) ]
23592406impl < I : fmt:: Debug , U : IntoIterator , F > fmt:: Debug for FlatMap < I , U , F >
23602407 where U :: IntoIter : fmt:: Debug
@@ -2513,7 +2560,7 @@ impl<I, U, F> FusedIterator for FlatMap<I, U, F>
25132560///
25142561/// [`fuse`]: trait.Iterator.html#method.fuse
25152562/// [`Iterator`]: trait.Iterator.html
2516- #[ derive( Clone , Debug ) ]
2563+ #[ derive( Copy , Clone , Debug ) ]
25172564#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
25182565#[ stable( feature = "rust1" , since = "1.0.0" ) ]
25192566pub struct Fuse < I > {
@@ -2740,7 +2787,7 @@ impl<I> ExactSizeIterator for Fuse<I> where I: ExactSizeIterator {
27402787/// [`Iterator`]: trait.Iterator.html
27412788#[ must_use = "iterator adaptors are lazy and do nothing unless consumed" ]
27422789#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2743- #[ derive( Clone ) ]
2790+ #[ derive( Copy , Clone ) ]
27442791pub struct Inspect < I , F > {
27452792 iter : I ,
27462793 f : F ,
0 commit comments