File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -1536,7 +1536,8 @@ impl str {
15361536 #[ inline]
15371537 pub fn split_once < ' a , P : Pattern < ' a > > ( & ' a self , delimiter : P ) -> Option < ( & ' a str , & ' a str ) > {
15381538 let ( start, end) = delimiter. into_searcher ( self ) . next_match ( ) ?;
1539- Some ( ( & self [ ..start] , & self [ end..] ) )
1539+ // SAFETY: `Searcher` is known to return valid indices.
1540+ unsafe { Some ( ( self . get_unchecked ( ..start) , self . get_unchecked ( end..) ) ) }
15401541 }
15411542
15421543 /// Splits the string on the last occurrence of the specified delimiter and
@@ -1556,7 +1557,8 @@ impl str {
15561557 P : Pattern < ' a , Searcher : ReverseSearcher < ' a > > ,
15571558 {
15581559 let ( start, end) = delimiter. into_searcher ( self ) . next_match_back ( ) ?;
1559- Some ( ( & self [ ..start] , & self [ end..] ) )
1560+ // SAFETY: `Searcher` is known to return valid indices.
1561+ unsafe { Some ( ( self . get_unchecked ( ..start) , self . get_unchecked ( end..) ) ) }
15601562 }
15611563
15621564 /// An iterator over the disjoint matches of a pattern within the given string
You can’t perform that action at this time.
0 commit comments