@@ -19,8 +19,9 @@ pub struct Zip<A, B> {
19
19
}
20
20
impl < A : Iterator , B : Iterator > Zip < A , B > {
21
21
pub ( in crate :: iter) fn new ( a : A , b : B ) -> Zip < A , B > {
22
- ZipImpl :: new ( a, b)
22
+ ZipNew :: new ( a, b)
23
23
}
24
+
24
25
fn super_nth ( & mut self , mut n : usize ) -> Option < ( A :: Item , B :: Item ) > {
25
26
while let Some ( x) = Iterator :: next ( self ) {
26
27
if n == 0 {
@@ -32,6 +33,39 @@ impl<A: Iterator, B: Iterator> Zip<A, B> {
32
33
}
33
34
}
34
35
36
+ #[ doc( hidden) ]
37
+ trait ZipNew < A , B > {
38
+ fn new ( a : A , b : B ) -> Self ;
39
+ }
40
+
41
+ #[ doc( hidden) ]
42
+ impl < A , B > ZipNew < A , B > for Zip < A , B >
43
+ where
44
+ A : Iterator ,
45
+ B : Iterator ,
46
+ {
47
+ default fn new ( a : A , b : B ) -> Self {
48
+ Zip {
49
+ a,
50
+ b,
51
+ index : 0 , // unused
52
+ len : 0 , // unused
53
+ }
54
+ }
55
+ }
56
+
57
+ #[ doc( hidden) ]
58
+ impl < A , B > ZipNew < A , B > for Zip < A , B >
59
+ where
60
+ A : TrustedRandomAccess + Iterator ,
61
+ B : TrustedRandomAccess + Iterator ,
62
+ {
63
+ fn new ( a : A , b : B ) -> Self {
64
+ let len = cmp:: min ( a. size ( ) , b. size ( ) ) ;
65
+ Zip { a, b, index : 0 , len }
66
+ }
67
+ }
68
+
35
69
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
36
70
impl < A , B > Iterator for Zip < A , B >
37
71
where
82
116
#[ doc( hidden) ]
83
117
trait ZipImpl < A , B > {
84
118
type Item ;
85
- fn new ( a : A , b : B ) -> Self ;
86
119
fn next ( & mut self ) -> Option < Self :: Item > ;
87
120
fn size_hint ( & self ) -> ( usize , Option < usize > ) ;
88
121
fn nth ( & mut self , n : usize ) -> Option < Self :: Item > ;
@@ -104,14 +137,6 @@ where
104
137
B : Iterator ,
105
138
{
106
139
type Item = ( A :: Item , B :: Item ) ;
107
- default fn new ( a : A , b : B ) -> Self {
108
- Zip {
109
- a,
110
- b,
111
- index : 0 , // unused
112
- len : 0 , // unused
113
- }
114
- }
115
140
116
141
#[ inline]
117
142
default fn next ( & mut self ) -> Option < ( A :: Item , B :: Item ) > {
@@ -183,11 +208,6 @@ where
183
208
A : TrustedRandomAccess + Iterator ,
184
209
B : TrustedRandomAccess + Iterator ,
185
210
{
186
- fn new ( a : A , b : B ) -> Self {
187
- let len = cmp:: min ( a. size ( ) , b. size ( ) ) ;
188
- Zip { a, b, index : 0 , len }
189
- }
190
-
191
211
#[ inline]
192
212
fn next ( & mut self ) -> Option < ( A :: Item , B :: Item ) > {
193
213
if self . index < self . len {
0 commit comments