@@ -195,6 +195,7 @@ pub unsafe trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
195
195
fn index_mut ( self , slice : & mut T ) -> & mut Self :: Output ;
196
196
}
197
197
198
+ /// The methods `index` and `index_mut` panic if the index is out of bounds.
198
199
#[ stable( feature = "slice_get_slice_impls" , since = "1.15.0" ) ]
199
200
#[ rustc_const_unstable( feature = "const_slice_index" , issue = "none" ) ]
200
201
unsafe impl < T > SliceIndex < [ T ] > for usize {
@@ -328,6 +329,9 @@ unsafe impl<T> SliceIndex<[T]> for ops::IndexRange {
328
329
}
329
330
}
330
331
332
+ /// The methods `index` and `index_mut` panic if:
333
+ /// - the start of the range is greater than the end of the range or
334
+ /// - the end of the range is out of bounds.
331
335
#[ stable( feature = "slice_get_slice_impls" , since = "1.15.0" ) ]
332
336
#[ rustc_const_unstable( feature = "const_slice_index" , issue = "none" ) ]
333
337
unsafe impl < T > SliceIndex < [ T ] > for ops:: Range < usize > {
@@ -416,6 +420,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
416
420
}
417
421
}
418
422
423
+ /// The methods `index` and `index_mut` panic if the end of the range is out of bounds.
419
424
#[ stable( feature = "slice_get_slice_impls" , since = "1.15.0" ) ]
420
425
#[ rustc_const_unstable( feature = "const_slice_index" , issue = "none" ) ]
421
426
unsafe impl < T > SliceIndex < [ T ] > for ops:: RangeTo < usize > {
@@ -454,6 +459,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeTo<usize> {
454
459
}
455
460
}
456
461
462
+ /// The methods `index` and `index_mut` panic if the start of the range is out of bounds.
457
463
#[ stable( feature = "slice_get_slice_impls" , since = "1.15.0" ) ]
458
464
#[ rustc_const_unstable( feature = "const_slice_index" , issue = "none" ) ]
459
465
unsafe impl < T > SliceIndex < [ T ] > for ops:: RangeFrom < usize > {
@@ -536,6 +542,10 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeFull {
536
542
}
537
543
}
538
544
545
+ /// The methods `index` and `index_mut` panic if:
546
+ /// - the end of the range is `usize::MAX` or
547
+ /// - the start of the range is greater than the end of the range or
548
+ /// - the end of the range is out of bounds.
539
549
#[ stable( feature = "inclusive_range" , since = "1.26.0" ) ]
540
550
#[ rustc_const_unstable( feature = "const_slice_index" , issue = "none" ) ]
541
551
unsafe impl < T > SliceIndex < [ T ] > for ops:: RangeInclusive < usize > {
@@ -580,6 +590,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
580
590
}
581
591
}
582
592
593
+ /// The methods `index` and `index_mut` panic if the end of the range is out of bounds.
583
594
#[ stable( feature = "inclusive_range" , since = "1.26.0" ) ]
584
595
#[ rustc_const_unstable( feature = "const_slice_index" , issue = "none" ) ]
585
596
unsafe impl < T > SliceIndex < [ T ] > for ops:: RangeToInclusive < usize > {
0 commit comments