@@ -1055,7 +1055,7 @@ impl<'a, P: Pattern<'a>> SplitInternal<'a, P> {
10551055 if !self . finished && ( self . allow_trailing_empty || self . end - self . start > 0 ) {
10561056 self . finished = true ;
10571057 unsafe {
1058- let string = self . matcher . haystack ( ) . slice_unchecked ( self . start , self . end ) ;
1058+ let string = self . matcher . haystack ( ) . get_unchecked ( self . start .. self . end ) ;
10591059 Some ( string)
10601060 }
10611061 } else {
@@ -1070,7 +1070,7 @@ impl<'a, P: Pattern<'a>> SplitInternal<'a, P> {
10701070 let haystack = self . matcher . haystack ( ) ;
10711071 match self . matcher . next_match ( ) {
10721072 Some ( ( a, b) ) => unsafe {
1073- let elt = haystack. slice_unchecked ( self . start , a) ;
1073+ let elt = haystack. get_unchecked ( self . start .. a) ;
10741074 self . start = b;
10751075 Some ( elt)
10761076 } ,
@@ -1095,13 +1095,13 @@ impl<'a, P: Pattern<'a>> SplitInternal<'a, P> {
10951095 let haystack = self . matcher . haystack ( ) ;
10961096 match self . matcher . next_match_back ( ) {
10971097 Some ( ( a, b) ) => unsafe {
1098- let elt = haystack. slice_unchecked ( b , self . end ) ;
1098+ let elt = haystack. get_unchecked ( b.. self . end ) ;
10991099 self . end = a;
11001100 Some ( elt)
11011101 } ,
11021102 None => unsafe {
11031103 self . finished = true ;
1104- Some ( haystack. slice_unchecked ( self . start , self . end ) )
1104+ Some ( haystack. get_unchecked ( self . start .. self . end ) )
11051105 } ,
11061106 }
11071107 }
@@ -1222,7 +1222,7 @@ impl<'a, P: Pattern<'a>> MatchIndicesInternal<'a, P> {
12221222 #[ inline]
12231223 fn next ( & mut self ) -> Option < ( usize , & ' a str ) > {
12241224 self . 0 . next_match ( ) . map ( |( start, end) | unsafe {
1225- ( start, self . 0 . haystack ( ) . slice_unchecked ( start, end) )
1225+ ( start, self . 0 . haystack ( ) . get_unchecked ( start.. end) )
12261226 } )
12271227 }
12281228
@@ -1231,7 +1231,7 @@ impl<'a, P: Pattern<'a>> MatchIndicesInternal<'a, P> {
12311231 where P :: Searcher : ReverseSearcher < ' a >
12321232 {
12331233 self . 0 . next_match_back ( ) . map ( |( start, end) | unsafe {
1234- ( start, self . 0 . haystack ( ) . slice_unchecked ( start, end) )
1234+ ( start, self . 0 . haystack ( ) . get_unchecked ( start.. end) )
12351235 } )
12361236 }
12371237}
@@ -1274,7 +1274,7 @@ impl<'a, P: Pattern<'a>> MatchesInternal<'a, P> {
12741274 fn next ( & mut self ) -> Option < & ' a str > {
12751275 self . 0 . next_match ( ) . map ( |( a, b) | unsafe {
12761276 // Indices are known to be on utf8 boundaries
1277- self . 0 . haystack ( ) . slice_unchecked ( a , b)
1277+ self . 0 . haystack ( ) . get_unchecked ( a.. b)
12781278 } )
12791279 }
12801280
@@ -1284,7 +1284,7 @@ impl<'a, P: Pattern<'a>> MatchesInternal<'a, P> {
12841284 {
12851285 self . 0 . next_match_back ( ) . map ( |( a, b) | unsafe {
12861286 // Indices are known to be on utf8 boundaries
1287- self . 0 . haystack ( ) . slice_unchecked ( a , b)
1287+ self . 0 . haystack ( ) . get_unchecked ( a.. b)
12881288 } )
12891289 }
12901290}
@@ -2453,6 +2453,7 @@ impl str {
24532453 /// }
24542454 /// ```
24552455 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
2456+ #[ rustc_deprecated( since = "1.29.0" , reason = "use `get_unchecked(begin..end)` instead" ) ]
24562457 #[ inline]
24572458 pub unsafe fn slice_unchecked ( & self , begin : usize , end : usize ) -> & str {
24582459 ( begin..end) . get_unchecked ( self )
@@ -2483,6 +2484,7 @@ impl str {
24832484 /// * `begin` and `end` must be byte positions within the string slice.
24842485 /// * `begin` and `end` must lie on UTF-8 sequence boundaries.
24852486 #[ stable( feature = "str_slice_mut" , since = "1.5.0" ) ]
2487+ #[ rustc_deprecated( since = "1.29.0" , reason = "use `get_unchecked_mut(begin..end)` instead" ) ]
24862488 #[ inline]
24872489 pub unsafe fn slice_mut_unchecked ( & mut self , begin : usize , end : usize ) -> & mut str {
24882490 ( begin..end) . get_unchecked_mut ( self )
@@ -2524,8 +2526,8 @@ impl str {
25242526 // is_char_boundary checks that the index is in [0, .len()]
25252527 if self . is_char_boundary ( mid) {
25262528 unsafe {
2527- ( self . slice_unchecked ( 0 , mid) ,
2528- self . slice_unchecked ( mid, self . len ( ) ) )
2529+ ( self . get_unchecked ( 0 .. mid) ,
2530+ self . get_unchecked ( mid.. self . len ( ) ) )
25292531 }
25302532 } else {
25312533 slice_error_fail ( self , 0 , mid)
@@ -3702,7 +3704,7 @@ impl str {
37023704 }
37033705 unsafe {
37043706 // Searcher is known to return valid indices
3705- self . slice_unchecked ( i , j)
3707+ self . get_unchecked ( i.. j)
37063708 }
37073709 }
37083710
@@ -3741,7 +3743,7 @@ impl str {
37413743 }
37423744 unsafe {
37433745 // Searcher is known to return valid indices
3744- self . slice_unchecked ( i , self . len ( ) )
3746+ self . get_unchecked ( i.. self . len ( ) )
37453747 }
37463748 }
37473749
@@ -3788,7 +3790,7 @@ impl str {
37883790 }
37893791 unsafe {
37903792 // Searcher is known to return valid indices
3791- self . slice_unchecked ( 0 , j)
3793+ self . get_unchecked ( 0 .. j)
37923794 }
37933795 }
37943796
0 commit comments