@@ -17,7 +17,12 @@ pub struct Zip<A, B> {
17
17
index : usize ,
18
18
len : usize ,
19
19
}
20
- impl < A : Iterator , B : Iterator > Zip < A , B > {
20
+
21
+ impl < A , B > Zip < A , B >
22
+ where
23
+ A : Iterator ,
24
+ B : Iterator ,
25
+ {
21
26
pub ( in crate :: iter) fn new ( a : A , b : B ) -> Zip < A , B > {
22
27
ZipNew :: new ( a, b)
23
28
}
66
71
}
67
72
}
68
73
69
- #[ stable( feature = "rust1" , since = "1.0.0" ) ]
70
- impl < A , B > Iterator for Zip < A , B >
71
- where
72
- A : Iterator ,
73
- B : Iterator ,
74
- {
75
- type Item = ( A :: Item , B :: Item ) ;
76
-
77
- #[ inline]
78
- fn next ( & mut self ) -> Option < Self :: Item > {
79
- ZipImpl :: next ( self )
80
- }
81
-
82
- #[ inline]
83
- fn size_hint ( & self ) -> ( usize , Option < usize > ) {
84
- ZipImpl :: size_hint ( self )
85
- }
86
-
87
- #[ inline]
88
- fn nth ( & mut self , n : usize ) -> Option < Self :: Item > {
89
- ZipImpl :: nth ( self , n)
90
- }
91
-
92
- #[ inline]
93
- unsafe fn __iterator_get_unchecked ( & mut self , idx : usize ) -> Self :: Item
94
- where
95
- Self : TrustedRandomAccess ,
96
- {
97
- // SAFETY: `ZipImpl::__iterator_get_unchecked` has same safety
98
- // requirements as `Iterator::__iterator_get_unchecked`.
99
- unsafe { ZipImpl :: get_unchecked ( self , idx) }
100
- }
101
- }
102
-
103
74
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
104
75
impl < A , B > DoubleEndedIterator for Zip < A , B >
105
76
where
@@ -175,22 +146,8 @@ where
175
146
}
176
147
}
177
148
178
- // Zip specialization trait
179
- #[ doc( hidden) ]
180
- trait ZipImpl < A , B > {
181
- type Item ;
182
- fn next ( & mut self ) -> Option < Self :: Item > ;
183
- fn size_hint ( & self ) -> ( usize , Option < usize > ) ;
184
- fn nth ( & mut self , n : usize ) -> Option < Self :: Item > ;
185
- // This has the same safety requirements as `Iterator::__iterator_get_unchecked`
186
- unsafe fn get_unchecked ( & mut self , idx : usize ) -> <Self as Iterator >:: Item
187
- where
188
- Self : Iterator + TrustedRandomAccess ;
189
- }
190
-
191
- // General Zip impl
192
- #[ doc( hidden) ]
193
- impl < A , B > ZipImpl < A , B > for Zip < A , B >
149
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
150
+ impl < A , B > Iterator for Zip < A , B >
194
151
where
195
152
A : Iterator ,
196
153
B : Iterator ,
@@ -226,16 +183,16 @@ where
226
183
( lower, upper)
227
184
}
228
185
229
- default unsafe fn get_unchecked ( & mut self , _idx : usize ) -> <Self as Iterator >:: Item
186
+ default unsafe fn __iterator_get_unchecked ( & mut self , _idx : usize ) -> <Self as Iterator >:: Item
230
187
where
231
188
Self : TrustedRandomAccess ,
232
189
{
233
190
unreachable ! ( "Always specialized" ) ;
234
191
}
235
192
}
236
193
237
- #[ doc ( hidden ) ]
238
- impl < A , B > ZipImpl < A , B > for Zip < A , B >
194
+ #[ stable ( feature = "rust1" , since = "1.0.0" ) ]
195
+ impl < A , B > Iterator for Zip < A , B >
239
196
where
240
197
A : TrustedRandomAccess + Iterator ,
241
198
B : TrustedRandomAccess + Iterator ,
@@ -295,7 +252,7 @@ where
295
252
}
296
253
297
254
#[ inline]
298
- unsafe fn get_unchecked ( & mut self , idx : usize ) -> <Self as Iterator >:: Item {
255
+ unsafe fn __iterator_get_unchecked ( & mut self , idx : usize ) -> <Self as Iterator >:: Item {
299
256
let idx = self . index + idx;
300
257
// SAFETY: the caller must uphold the contract for
301
258
// `Iterator::__iterator_get_unchecked`.
0 commit comments