File tree 2 files changed +6
-3
lines changed
2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -48,11 +48,11 @@ impl<I> IteratorIndex<I> for RangeInclusive<usize>
48
48
where
49
49
I : Iterator ,
50
50
{
51
- type Output = Take < Skip < I > > ;
51
+ type Output = Skip < Take < I > > ;
52
52
53
53
fn index ( self , iter : I ) -> Self :: Output {
54
- iter . skip ( * self . start ( ) )
55
- . take ( ( 1 + * self . end ( ) ) . saturating_sub ( * self . start ( ) ) )
54
+ assert_ne ! ( * self . end ( ) , usize :: MAX ) ;
55
+ iter . take ( self . end ( ) + 1 ) . skip ( * self . start ( ) )
56
56
}
57
57
}
58
58
74
74
type Output = Take < I > ;
75
75
76
76
fn index ( self , iter : I ) -> Self :: Output {
77
+ assert_ne ! ( self . end, usize :: MAX ) ;
77
78
iter. take ( self . end + 1 )
78
79
}
79
80
}
Original file line number Diff line number Diff line change @@ -511,6 +511,8 @@ pub trait Itertools: Iterator {
511
511
///
512
512
/// Works similarly to [`slice::get`](https://doc.rust-lang.org/std/primitive.slice.html#method.get).
513
513
///
514
+ /// **Panics** if the range includes `usize::MAX`.
515
+ ///
514
516
/// It's a generalisation of [`Iterator::take`] and [`Iterator::skip`],
515
517
/// and uses these under the hood.
516
518
/// Therefore, the resulting iterator is [`DoubleEndedIterator`]
You can’t perform that action at this time.
0 commit comments