@@ -26,7 +26,12 @@ pub(crate) use self::zip::TrustedRandomAccess;
2626#[ must_use = "iterators are lazy and do nothing unless consumed" ]
2727#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2828pub struct Rev < T > {
29- pub ( super ) iter : T
29+ iter : T
30+ }
31+ impl < T > Rev < T > {
32+ pub ( super ) fn new ( iter : T ) -> Rev < T > {
33+ Rev { iter }
34+ }
3035}
3136
3237#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -127,7 +132,12 @@ unsafe impl<I> TrustedLen for Rev<I>
127132#[ must_use = "iterators are lazy and do nothing unless consumed" ]
128133#[ derive( Clone , Debug ) ]
129134pub struct Copied < I > {
130- pub ( super ) it : I ,
135+ it : I ,
136+ }
137+ impl < I > Copied < I > {
138+ pub ( super ) fn new ( it : I ) -> Copied < I > {
139+ Copied { it }
140+ }
131141}
132142
133143#[ unstable( feature = "iter_copied" , issue = "57127" ) ]
@@ -227,7 +237,12 @@ unsafe impl<'a, I, T: 'a> TrustedLen for Copied<I>
227237#[ must_use = "iterators are lazy and do nothing unless consumed" ]
228238#[ derive( Clone , Debug ) ]
229239pub struct Cloned < I > {
230- pub ( super ) it : I ,
240+ it : I ,
241+ }
242+ impl < I > Cloned < I > {
243+ pub ( super ) fn new ( it : I ) -> Cloned < I > {
244+ Cloned { it }
245+ }
231246}
232247
233248#[ stable( feature = "iter_cloned" , since = "1.1.0" ) ]
@@ -525,8 +540,13 @@ impl<I> ExactSizeIterator for StepBy<I> where I: ExactSizeIterator {}
525540#[ stable( feature = "rust1" , since = "1.0.0" ) ]
526541#[ derive( Clone ) ]
527542pub struct Map < I , F > {
528- pub ( super ) iter : I ,
529- pub ( super ) f : F ,
543+ iter : I ,
544+ f : F ,
545+ }
546+ impl < I , F > Map < I , F > {
547+ pub ( super ) fn new ( iter : I , f : F ) -> Map < I , F > {
548+ Map { iter, f }
549+ }
530550}
531551
532552#[ stable( feature = "core_impl_debug" , since = "1.9.0" ) ]
@@ -636,8 +656,13 @@ unsafe impl<B, I, F> TrustedRandomAccess for Map<I, F>
636656#[ stable( feature = "rust1" , since = "1.0.0" ) ]
637657#[ derive( Clone ) ]
638658pub struct Filter < I , P > {
639- pub ( super ) iter : I ,
640- pub ( super ) predicate : P ,
659+ iter : I ,
660+ predicate : P ,
661+ }
662+ impl < I , P > Filter < I , P > {
663+ pub ( super ) fn new ( iter : I , predicate : P ) -> Filter < I , P > {
664+ Filter { iter, predicate }
665+ }
641666}
642667
643668#[ stable( feature = "core_impl_debug" , since = "1.9.0" ) ]
@@ -768,8 +793,13 @@ impl<I: FusedIterator, P> FusedIterator for Filter<I, P>
768793#[ stable( feature = "rust1" , since = "1.0.0" ) ]
769794#[ derive( Clone ) ]
770795pub struct FilterMap < I , F > {
771- pub ( super ) iter : I ,
772- pub ( super ) f : F ,
796+ iter : I ,
797+ f : F ,
798+ }
799+ impl < I , F > FilterMap < I , F > {
800+ pub ( super ) fn new ( iter : I , f : F ) -> FilterMap < I , F > {
801+ FilterMap { iter, f }
802+ }
773803}
774804
775805#[ stable( feature = "core_impl_debug" , since = "1.9.0" ) ]
@@ -1377,8 +1407,13 @@ impl<I, P> FusedIterator for TakeWhile<I, P>
13771407#[ must_use = "iterators are lazy and do nothing unless consumed" ]
13781408#[ stable( feature = "rust1" , since = "1.0.0" ) ]
13791409pub struct Skip < I > {
1380- pub ( super ) iter : I ,
1381- pub ( super ) n : usize
1410+ iter : I ,
1411+ n : usize
1412+ }
1413+ impl < I > Skip < I > {
1414+ pub ( super ) fn new ( iter : I , n : usize ) -> Skip < I > {
1415+ Skip { iter, n }
1416+ }
13821417}
13831418
13841419#[ stable( feature = "rust1" , since = "1.0.0" ) ]
@@ -1518,6 +1553,11 @@ pub struct Take<I> {
15181553 pub ( super ) iter : I ,
15191554 pub ( super ) n : usize
15201555}
1556+ impl < I > Take < I > {
1557+ pub ( super ) fn new ( iter : I , n : usize ) -> Take < I > {
1558+ Take { iter, n }
1559+ }
1560+ }
15211561
15221562#[ stable( feature = "rust1" , since = "1.0.0" ) ]
15231563impl < I > Iterator for Take < I > where I : Iterator {
@@ -1603,9 +1643,14 @@ unsafe impl<I: TrustedLen> TrustedLen for Take<I> {}
16031643#[ stable( feature = "rust1" , since = "1.0.0" ) ]
16041644#[ derive( Clone ) ]
16051645pub struct Scan < I , St , F > {
1606- pub ( super ) iter : I ,
1607- pub ( super ) f : F ,
1608- pub ( super ) state : St ,
1646+ iter : I ,
1647+ f : F ,
1648+ state : St ,
1649+ }
1650+ impl < I , St , F > Scan < I , St , F > {
1651+ pub ( super ) fn new ( iter : I , state : St , f : F ) -> Scan < I , St , F > {
1652+ Scan { iter, state, f }
1653+ }
16091654}
16101655
16111656#[ stable( feature = "core_impl_debug" , since = "1.9.0" ) ]
@@ -1893,8 +1938,13 @@ impl<I> ExactSizeIterator for Fuse<I> where I: ExactSizeIterator {
18931938#[ stable( feature = "rust1" , since = "1.0.0" ) ]
18941939#[ derive( Clone ) ]
18951940pub struct Inspect < I , F > {
1896- pub ( super ) iter : I ,
1897- pub ( super ) f : F ,
1941+ iter : I ,
1942+ f : F ,
1943+ }
1944+ impl < I , F > Inspect < I , F > {
1945+ pub ( super ) fn new ( iter : I , f : F ) -> Inspect < I , F > {
1946+ Inspect { iter, f }
1947+ }
18981948}
18991949
19001950#[ stable( feature = "core_impl_debug" , since = "1.9.0" ) ]
0 commit comments