@@ -1301,9 +1301,9 @@ where
13011301impl < ' a , P : Pattern < ' a > > MatchIndicesInternal < ' a , P > {
13021302 #[ inline]
13031303 fn next ( & mut self ) -> Option < ( usize , & ' a str ) > {
1304- // SAFETY: `Searcher` guarantees that `start` and `end` lie on unicode boundaries.
13051304 self . 0
13061305 . next_match ( )
1306+ // SAFETY: `Searcher` guarantees that `start` and `end` lie on unicode boundaries.
13071307 . map ( |( start, end) | unsafe { ( start, self . 0 . haystack ( ) . get_unchecked ( start..end) ) } )
13081308 }
13091309
@@ -1312,9 +1312,9 @@ impl<'a, P: Pattern<'a>> MatchIndicesInternal<'a, P> {
13121312 where
13131313 P :: Searcher : ReverseSearcher < ' a > ,
13141314 {
1315- // SAFETY: `Searcher` guarantees that `start` and `end` lie on unicode boundaries.
13161315 self . 0
13171316 . next_match_back ( )
1317+ // SAFETY: `Searcher` guarantees that `start` and `end` lie on unicode boundaries.
13181318 . map ( |( start, end) | unsafe { ( start, self . 0 . haystack ( ) . get_unchecked ( start..end) ) } )
13191319 }
13201320}
@@ -3901,8 +3901,8 @@ impl str {
39013901 "The first search step from Searcher \
39023902 must include the first character"
39033903 ) ;
3904+ // SAFETY: `Searcher` is known to return valid indices.
39043905 unsafe {
3905- // Searcher is known to return valid indices.
39063906 Some ( self . get_unchecked ( len..) )
39073907 }
39083908 } else {
@@ -3942,8 +3942,8 @@ impl str {
39423942 "The first search step from ReverseSearcher \
39433943 must include the last character"
39443944 ) ;
3945+ // SAFETY: `Searcher` is known to return valid indices.
39453946 unsafe {
3946- // Searcher is known to return valid indices.
39473947 Some ( self . get_unchecked ( ..start) )
39483948 }
39493949 } else {
@@ -4381,8 +4381,8 @@ impl Default for &str {
43814381#[ stable( feature = "default_mut_str" , since = "1.28.0" ) ]
43824382impl Default for & mut str {
43834383 /// Creates an empty mutable str
4384- // SAFETY: `str` is guranteed to be UTF-8.
43854384 fn default ( ) -> Self {
4385+ // SAFETY: The empty string is valid UTF-8.
43864386 unsafe { from_utf8_unchecked_mut ( & mut [ ] ) }
43874387 }
43884388}
0 commit comments