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