@@ -398,39 +398,35 @@ unsafe impl SliceIndex<str> for ops::RangeInclusive<usize> {
398398 type Output = str ;
399399 #[ inline]
400400 fn get ( self , slice : & str ) -> Option < & Self :: Output > {
401- if * self . end ( ) == usize:: MAX { None } else { ( * self . start ( ) .. self . end ( ) + 1 ) . get ( slice) }
401+ if * self . end ( ) == usize:: MAX { None } else { self . into_slice_range ( ) . get ( slice) }
402402 }
403403 #[ inline]
404404 fn get_mut ( self , slice : & mut str ) -> Option < & mut Self :: Output > {
405- if * self . end ( ) == usize:: MAX {
406- None
407- } else {
408- ( * self . start ( ) ..self . end ( ) + 1 ) . get_mut ( slice)
409- }
405+ if * self . end ( ) == usize:: MAX { None } else { self . into_slice_range ( ) . get_mut ( slice) }
410406 }
411407 #[ inline]
412408 unsafe fn get_unchecked ( self , slice : * const str ) -> * const Self :: Output {
413409 // SAFETY: the caller must uphold the safety contract for `get_unchecked`.
414- unsafe { ( * self . start ( ) .. self . end ( ) + 1 ) . get_unchecked ( slice) }
410+ unsafe { self . into_slice_range ( ) . get_unchecked ( slice) }
415411 }
416412 #[ inline]
417413 unsafe fn get_unchecked_mut ( self , slice : * mut str ) -> * mut Self :: Output {
418414 // SAFETY: the caller must uphold the safety contract for `get_unchecked_mut`.
419- unsafe { ( * self . start ( ) .. self . end ( ) + 1 ) . get_unchecked_mut ( slice) }
415+ unsafe { self . into_slice_range ( ) . get_unchecked_mut ( slice) }
420416 }
421417 #[ inline]
422418 fn index ( self , slice : & str ) -> & Self :: Output {
423419 if * self . end ( ) == usize:: MAX {
424420 str_index_overflow_fail ( ) ;
425421 }
426- ( * self . start ( ) .. self . end ( ) + 1 ) . index ( slice)
422+ self . into_slice_range ( ) . index ( slice)
427423 }
428424 #[ inline]
429425 fn index_mut ( self , slice : & mut str ) -> & mut Self :: Output {
430426 if * self . end ( ) == usize:: MAX {
431427 str_index_overflow_fail ( ) ;
432428 }
433- ( * self . start ( ) .. self . end ( ) + 1 ) . index_mut ( slice)
429+ self . into_slice_range ( ) . index_mut ( slice)
434430 }
435431}
436432
0 commit comments