File tree 1 file changed +16
-0
lines changed
library/core/src/slice/iter
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -185,6 +185,14 @@ macro_rules! iterator {
185
185
}
186
186
}
187
187
188
+ #[ inline]
189
+ fn advance_by( & mut self , n: usize ) -> Result <( ) , usize >{
190
+ let advance = cmp:: min( n, len!( self ) ) ;
191
+ // SAFETY: `advance` does not exceed `self.len()` by construction
192
+ unsafe { self . post_inc_start( advance as isize ) } ;
193
+ if advance == n { Ok ( ( ) ) } else { Err ( advance) }
194
+ }
195
+
188
196
#[ inline]
189
197
fn last( mut self ) -> Option <$elem> {
190
198
self . next_back( )
@@ -371,6 +379,14 @@ macro_rules! iterator {
371
379
Some ( next_back_unchecked!( self ) )
372
380
}
373
381
}
382
+
383
+ #[ inline]
384
+ fn advance_back_by( & mut self , n: usize ) -> Result <( ) , usize > {
385
+ let advance = cmp:: min( n, len!( self ) ) ;
386
+ // SAFETY: `advance` does not exceed `self.len()` by construction
387
+ unsafe { self . pre_dec_end( advance as isize ) } ;
388
+ if advance == n { Ok ( ( ) ) } else { Err ( advance) }
389
+ }
374
390
}
375
391
376
392
#[ stable( feature = "fused" , since = "1.26.0" ) ]
You can’t perform that action at this time.
0 commit comments