@@ -195,6 +195,7 @@ pub unsafe trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
195195 fn index_mut ( self , slice : & mut T ) -> & mut Self :: Output ;
196196}
197197
198+ /// The methods `index` and `index_mut` panic if the index is out of bounds.
198199#[ stable( feature = "slice_get_slice_impls" , since = "1.15.0" ) ]
199200#[ rustc_const_unstable( feature = "const_slice_index" , issue = "none" ) ]
200201unsafe impl < T > SliceIndex < [ T ] > for usize {
@@ -328,6 +329,9 @@ unsafe impl<T> SliceIndex<[T]> for ops::IndexRange {
328329 }
329330}
330331
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.
331335#[ stable( feature = "slice_get_slice_impls" , since = "1.15.0" ) ]
332336#[ rustc_const_unstable( feature = "const_slice_index" , issue = "none" ) ]
333337unsafe impl < T > SliceIndex < [ T ] > for ops:: Range < usize > {
@@ -416,6 +420,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::Range<usize> {
416420 }
417421}
418422
423+ /// The methods `index` and `index_mut` panic if the end of the range is out of bounds.
419424#[ stable( feature = "slice_get_slice_impls" , since = "1.15.0" ) ]
420425#[ rustc_const_unstable( feature = "const_slice_index" , issue = "none" ) ]
421426unsafe impl < T > SliceIndex < [ T ] > for ops:: RangeTo < usize > {
@@ -454,6 +459,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeTo<usize> {
454459 }
455460}
456461
462+ /// The methods `index` and `index_mut` panic if the start of the range is out of bounds.
457463#[ stable( feature = "slice_get_slice_impls" , since = "1.15.0" ) ]
458464#[ rustc_const_unstable( feature = "const_slice_index" , issue = "none" ) ]
459465unsafe impl < T > SliceIndex < [ T ] > for ops:: RangeFrom < usize > {
@@ -536,6 +542,10 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeFull {
536542 }
537543}
538544
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.
539549#[ stable( feature = "inclusive_range" , since = "1.26.0" ) ]
540550#[ rustc_const_unstable( feature = "const_slice_index" , issue = "none" ) ]
541551unsafe impl < T > SliceIndex < [ T ] > for ops:: RangeInclusive < usize > {
@@ -580,6 +590,7 @@ unsafe impl<T> SliceIndex<[T]> for ops::RangeInclusive<usize> {
580590 }
581591}
582592
593+ /// The methods `index` and `index_mut` panic if the end of the range is out of bounds.
583594#[ stable( feature = "inclusive_range" , since = "1.26.0" ) ]
584595#[ rustc_const_unstable( feature = "const_slice_index" , issue = "none" ) ]
585596unsafe impl < T > SliceIndex < [ T ] > for ops:: RangeToInclusive < usize > {
0 commit comments