Skip to content

Commit 2c034b4

Browse files
committed
Update from upstream 1f399d0, prepare for rust-lang/rust#124056
1 parent f192a48 commit 2c034b4

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/range.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,13 @@ macro_rules! indexed_range_impl {
213213
}
214214

215215
trait UnindexedRangeLen<L> {
216-
fn len(&self) -> L;
216+
fn unindexed_len(&self) -> L;
217217
}
218218

219219
macro_rules! unindexed_range_impl {
220220
( $t:ty, $len_t:ty ) => {
221221
impl UnindexedRangeLen<$len_t> for Range<$t> {
222-
fn len(&self) -> $len_t {
222+
fn unindexed_len(&self) -> $len_t {
223223
let &Range { start, end } = self;
224224
if end > start {
225225
end.wrapping_sub(start) as $len_t
@@ -253,15 +253,15 @@ macro_rules! unindexed_range_impl {
253253
}
254254

255255
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()
257257
}
258258
}
259259

260260
impl UnindexedProducer for IterProducer<$t> {
261261
type Item = $t;
262262

263263
fn split(mut self) -> (Self, Option<Self>) {
264-
let index = self.range.len() / 2;
264+
let index = self.range.unindexed_len() / 2;
265265
if index > 0 {
266266
let mid = self.range.start.wrapping_add(index as $t);
267267
let right = mid..self.range.end;
@@ -387,11 +387,14 @@ fn test_i128_len_doesnt_overflow() {
387387
range: 0..octillion,
388388
};
389389

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+
);
393396

394-
assert_eq!(u128::MAX, (i128::MIN..i128::MAX).len());
397+
assert_eq!(u128::MAX, (i128::MIN..i128::MAX).unindexed_len());
395398
}
396399

397400
#[test]

0 commit comments

Comments
 (0)