File tree 1 file changed +5
-23
lines changed
1 file changed +5
-23
lines changed Original file line number Diff line number Diff line change @@ -444,32 +444,14 @@ impl<A: Step> Iterator for ops::RangeInclusive<A> {
444
444
}
445
445
Try :: from_ok ( accum)
446
446
}
447
- }
448
447
449
- macro_rules! impl_inclusive_range_count {
450
- ( $t: ty) => {
451
- #[ unstable( feature = "inclusive_range" , reason = "recently added, follows RFC" , issue = "28237" ) ]
452
- impl Iterator for ops:: RangeInclusive <$t> {
453
- #[ inline]
454
- fn count( self ) -> usize {
455
- ( self . end. wrapping_sub( self . start) as usize ) . wrapping_add( 1 )
456
- }
457
- }
458
- } ;
448
+ #[ inline]
449
+ fn count ( self ) -> usize {
450
+ <A as Step >:: steps_between ( & self . start , & self . end )
451
+ . expect ( "Overflow on `RangeInclusive::count()`" ) + 1
452
+ }
459
453
}
460
454
461
- impl_inclusive_range_count ! ( u8 ) ;
462
- impl_inclusive_range_count ! ( u16 ) ;
463
- impl_inclusive_range_count ! ( u32 ) ;
464
- impl_inclusive_range_count ! ( u64 ) ;
465
- impl_inclusive_range_count ! ( usize ) ;
466
-
467
- impl_inclusive_range_count ! ( i8 ) ;
468
- impl_inclusive_range_count ! ( i16 ) ;
469
- impl_inclusive_range_count ! ( i32 ) ;
470
- impl_inclusive_range_count ! ( i64 ) ;
471
- impl_inclusive_range_count ! ( isize ) ;
472
-
473
455
#[ unstable( feature = "inclusive_range" , reason = "recently added, follows RFC" , issue = "28237" ) ]
474
456
impl < A : Step > DoubleEndedIterator for ops:: RangeInclusive < A > {
475
457
#[ inline]
You can’t perform that action at this time.
0 commit comments