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 @@ -1524,7 +1524,8 @@ impl str {
15241524 #[ inline]
15251525 pub fn split_once < ' a , P : Pattern < ' a > > ( & ' a self , delimiter : P ) -> Option < ( & ' a str , & ' a str ) > {
15261526 let ( start, end) = delimiter. into_searcher ( self ) . next_match ( ) ?;
1527- Some ( ( & self [ ..start] , & self [ end..] ) )
1527+ // SAFETY: `Searcher` is known to return valid indices.
1528+ unsafe { Some ( ( self . get_unchecked ( ..start) , self . get_unchecked ( end..) ) ) }
15281529 }
15291530
15301531 /// Splits the string on the last occurrence of the specified delimiter and
@@ -1544,7 +1545,8 @@ impl str {
15441545 P : Pattern < ' a , Searcher : ReverseSearcher < ' a > > ,
15451546 {
15461547 let ( start, end) = delimiter. into_searcher ( self ) . next_match_back ( ) ?;
1547- Some ( ( & self [ ..start] , & self [ end..] ) )
1548+ // SAFETY: `Searcher` is known to return valid indices.
1549+ unsafe { Some ( ( self . get_unchecked ( ..start) , self . get_unchecked ( end..) ) ) }
15481550 }
15491551
15501552 /// 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