@@ -213,13 +213,13 @@ macro_rules! indexed_range_impl {
213
213
}
214
214
215
215
trait UnindexedRangeLen < L > {
216
- fn len ( & self ) -> L ;
216
+ fn unindexed_len ( & self ) -> L ;
217
217
}
218
218
219
219
macro_rules! unindexed_range_impl {
220
220
( $t: ty, $len_t: ty ) => {
221
221
impl UnindexedRangeLen <$len_t> for Range <$t> {
222
- fn len ( & self ) -> $len_t {
222
+ fn unindexed_len ( & self ) -> $len_t {
223
223
let & Range { start, end } = self ;
224
224
if end > start {
225
225
end. wrapping_sub( start) as $len_t
@@ -253,15 +253,15 @@ macro_rules! unindexed_range_impl {
253
253
}
254
254
255
255
fn opt_len( iter: & Iter <$t>) -> Option <usize > {
256
- usize :: try_from( iter. range. len ( ) ) . ok( )
256
+ usize :: try_from( iter. range. unindexed_len ( ) ) . ok( )
257
257
}
258
258
}
259
259
260
260
impl UnindexedProducer for IterProducer <$t> {
261
261
type Item = $t;
262
262
263
263
fn split( mut self ) -> ( Self , Option <Self >) {
264
- let index = self . range. len ( ) / 2 ;
264
+ let index = self . range. unindexed_len ( ) / 2 ;
265
265
if index > 0 {
266
266
let mid = self . range. start. wrapping_add( index as $t) ;
267
267
let right = mid..self . range. end;
@@ -387,11 +387,14 @@ fn test_i128_len_doesnt_overflow() {
387
387
range : 0 ..octillion,
388
388
} ;
389
389
390
- assert_eq ! ( octillion as u128 , producer. range. len( ) ) ;
391
- assert_eq ! ( octillion as u128 , ( 0 ..octillion) . len( ) ) ;
392
- assert_eq ! ( 2 * octillion as u128 , ( -octillion..octillion) . len( ) ) ;
390
+ assert_eq ! ( octillion as u128 , producer. range. unindexed_len( ) ) ;
391
+ assert_eq ! ( octillion as u128 , ( 0 ..octillion) . unindexed_len( ) ) ;
392
+ assert_eq ! (
393
+ 2 * octillion as u128 ,
394
+ ( -octillion..octillion) . unindexed_len( )
395
+ ) ;
393
396
394
- assert_eq ! ( u128 :: MAX , ( i128 :: MIN ..i128 :: MAX ) . len ( ) ) ;
397
+ assert_eq ! ( u128 :: MAX , ( i128 :: MIN ..i128 :: MAX ) . unindexed_len ( ) ) ;
395
398
}
396
399
397
400
#[ test]
0 commit comments