@@ -1055,7 +1055,7 @@ impl<'a, P: Pattern<'a>> SplitInternal<'a, P> {
1055
1055
if !self . finished && ( self . allow_trailing_empty || self . end - self . start > 0 ) {
1056
1056
self . finished = true ;
1057
1057
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 ) ;
1059
1059
Some ( string)
1060
1060
}
1061
1061
} else {
@@ -1070,7 +1070,7 @@ impl<'a, P: Pattern<'a>> SplitInternal<'a, P> {
1070
1070
let haystack = self . matcher . haystack ( ) ;
1071
1071
match self . matcher . next_match ( ) {
1072
1072
Some ( ( a, b) ) => unsafe {
1073
- let elt = haystack. slice_unchecked ( self . start , a) ;
1073
+ let elt = haystack. get_unchecked ( self . start .. a) ;
1074
1074
self . start = b;
1075
1075
Some ( elt)
1076
1076
} ,
@@ -1095,13 +1095,13 @@ impl<'a, P: Pattern<'a>> SplitInternal<'a, P> {
1095
1095
let haystack = self . matcher . haystack ( ) ;
1096
1096
match self . matcher . next_match_back ( ) {
1097
1097
Some ( ( a, b) ) => unsafe {
1098
- let elt = haystack. slice_unchecked ( b , self . end ) ;
1098
+ let elt = haystack. get_unchecked ( b.. self . end ) ;
1099
1099
self . end = a;
1100
1100
Some ( elt)
1101
1101
} ,
1102
1102
None => unsafe {
1103
1103
self . finished = true ;
1104
- Some ( haystack. slice_unchecked ( self . start , self . end ) )
1104
+ Some ( haystack. get_unchecked ( self . start .. self . end ) )
1105
1105
} ,
1106
1106
}
1107
1107
}
@@ -1222,7 +1222,7 @@ impl<'a, P: Pattern<'a>> MatchIndicesInternal<'a, P> {
1222
1222
#[ inline]
1223
1223
fn next ( & mut self ) -> Option < ( usize , & ' a str ) > {
1224
1224
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) )
1226
1226
} )
1227
1227
}
1228
1228
@@ -1231,7 +1231,7 @@ impl<'a, P: Pattern<'a>> MatchIndicesInternal<'a, P> {
1231
1231
where P :: Searcher : ReverseSearcher < ' a >
1232
1232
{
1233
1233
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) )
1235
1235
} )
1236
1236
}
1237
1237
}
@@ -1274,7 +1274,7 @@ impl<'a, P: Pattern<'a>> MatchesInternal<'a, P> {
1274
1274
fn next ( & mut self ) -> Option < & ' a str > {
1275
1275
self . 0 . next_match ( ) . map ( |( a, b) | unsafe {
1276
1276
// Indices are known to be on utf8 boundaries
1277
- self . 0 . haystack ( ) . slice_unchecked ( a , b)
1277
+ self . 0 . haystack ( ) . get_unchecked ( a.. b)
1278
1278
} )
1279
1279
}
1280
1280
@@ -1284,7 +1284,7 @@ impl<'a, P: Pattern<'a>> MatchesInternal<'a, P> {
1284
1284
{
1285
1285
self . 0 . next_match_back ( ) . map ( |( a, b) | unsafe {
1286
1286
// Indices are known to be on utf8 boundaries
1287
- self . 0 . haystack ( ) . slice_unchecked ( a , b)
1287
+ self . 0 . haystack ( ) . get_unchecked ( a.. b)
1288
1288
} )
1289
1289
}
1290
1290
}
@@ -2453,6 +2453,7 @@ impl str {
2453
2453
/// }
2454
2454
/// ```
2455
2455
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
2456
+ #[ rustc_deprecated( since = "1.29.0" , reason = "use `get_unchecked(begin..end)` instead" ) ]
2456
2457
#[ inline]
2457
2458
pub unsafe fn slice_unchecked ( & self , begin : usize , end : usize ) -> & str {
2458
2459
( begin..end) . get_unchecked ( self )
@@ -2483,6 +2484,7 @@ impl str {
2483
2484
/// * `begin` and `end` must be byte positions within the string slice.
2484
2485
/// * `begin` and `end` must lie on UTF-8 sequence boundaries.
2485
2486
#[ stable( feature = "str_slice_mut" , since = "1.5.0" ) ]
2487
+ #[ rustc_deprecated( since = "1.29.0" , reason = "use `get_unchecked_mut(begin..end)` instead" ) ]
2486
2488
#[ inline]
2487
2489
pub unsafe fn slice_mut_unchecked ( & mut self , begin : usize , end : usize ) -> & mut str {
2488
2490
( begin..end) . get_unchecked_mut ( self )
@@ -2524,8 +2526,8 @@ impl str {
2524
2526
// is_char_boundary checks that the index is in [0, .len()]
2525
2527
if self . is_char_boundary ( mid) {
2526
2528
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 ( ) ) )
2529
2531
}
2530
2532
} else {
2531
2533
slice_error_fail ( self , 0 , mid)
@@ -3702,7 +3704,7 @@ impl str {
3702
3704
}
3703
3705
unsafe {
3704
3706
// Searcher is known to return valid indices
3705
- self . slice_unchecked ( i , j)
3707
+ self . get_unchecked ( i.. j)
3706
3708
}
3707
3709
}
3708
3710
@@ -3741,7 +3743,7 @@ impl str {
3741
3743
}
3742
3744
unsafe {
3743
3745
// Searcher is known to return valid indices
3744
- self . slice_unchecked ( i , self . len ( ) )
3746
+ self . get_unchecked ( i.. self . len ( ) )
3745
3747
}
3746
3748
}
3747
3749
@@ -3788,7 +3790,7 @@ impl str {
3788
3790
}
3789
3791
unsafe {
3790
3792
// Searcher is known to return valid indices
3791
- self . slice_unchecked ( 0 , j)
3793
+ self . get_unchecked ( 0 .. j)
3792
3794
}
3793
3795
}
3794
3796
0 commit comments