File tree 1 file changed +6
-26
lines changed
1 file changed +6
-26
lines changed Original file line number Diff line number Diff line change @@ -253,8 +253,12 @@ pub trait Iterator {
253
253
/// ```
254
254
#[ inline]
255
255
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
256
- fn nth ( & mut self , n : usize ) -> Option < Self :: Item > {
257
- self . spec_nth ( n)
256
+ fn nth ( & mut self , mut n : usize ) -> Option < Self :: Item > {
257
+ for x in self {
258
+ if n == 0 { return Some ( x) }
259
+ n -= 1 ;
260
+ }
261
+ None
258
262
}
259
263
260
264
/// Creates an iterator starting at the same point, but stepping by
@@ -2381,27 +2385,3 @@ impl<'a, I: Iterator + ?Sized> Iterator for &'a mut I {
2381
2385
( * * self ) . nth ( n)
2382
2386
}
2383
2387
}
2384
-
2385
-
2386
- trait SpecIterator : Iterator {
2387
- fn spec_nth ( & mut self , n : usize ) -> Option < Self :: Item > ;
2388
- }
2389
-
2390
- impl < I : Iterator + ?Sized > SpecIterator for I {
2391
- default fn spec_nth ( & mut self , mut n : usize ) -> Option < Self :: Item > {
2392
- for x in self {
2393
- if n == 0 { return Some ( x) }
2394
- n -= 1 ;
2395
- }
2396
- None
2397
- }
2398
- }
2399
-
2400
- impl < I : Iterator + Sized > SpecIterator for I {
2401
- fn spec_nth ( & mut self , n : usize ) -> Option < Self :: Item > {
2402
- self . try_fold ( n, move |i, x| {
2403
- if i == 0 { LoopState :: Break ( x) }
2404
- else { LoopState :: Continue ( i - 1 ) }
2405
- } ) . break_value ( )
2406
- }
2407
- }
You can’t perform that action at this time.
0 commit comments