@@ -1301,9 +1301,9 @@ where
1301
1301
impl < ' a , P : Pattern < ' a > > MatchIndicesInternal < ' a , P > {
1302
1302
#[ inline]
1303
1303
fn next ( & mut self ) -> Option < ( usize , & ' a str ) > {
1304
- // SAFETY: `Searcher` guarantees that `start` and `end` lie on unicode boundaries.
1305
1304
self . 0
1306
1305
. next_match ( )
1306
+ // SAFETY: `Searcher` guarantees that `start` and `end` lie on unicode boundaries.
1307
1307
. map ( |( start, end) | unsafe { ( start, self . 0 . haystack ( ) . get_unchecked ( start..end) ) } )
1308
1308
}
1309
1309
@@ -1312,9 +1312,9 @@ impl<'a, P: Pattern<'a>> MatchIndicesInternal<'a, P> {
1312
1312
where
1313
1313
P :: Searcher : ReverseSearcher < ' a > ,
1314
1314
{
1315
- // SAFETY: `Searcher` guarantees that `start` and `end` lie on unicode boundaries.
1316
1315
self . 0
1317
1316
. next_match_back ( )
1317
+ // SAFETY: `Searcher` guarantees that `start` and `end` lie on unicode boundaries.
1318
1318
. map ( |( start, end) | unsafe { ( start, self . 0 . haystack ( ) . get_unchecked ( start..end) ) } )
1319
1319
}
1320
1320
}
@@ -3901,8 +3901,8 @@ impl str {
3901
3901
"The first search step from Searcher \
3902
3902
must include the first character"
3903
3903
) ;
3904
+ // SAFETY: `Searcher` is known to return valid indices.
3904
3905
unsafe {
3905
- // Searcher is known to return valid indices.
3906
3906
Some ( self . get_unchecked ( len..) )
3907
3907
}
3908
3908
} else {
@@ -3942,8 +3942,8 @@ impl str {
3942
3942
"The first search step from ReverseSearcher \
3943
3943
must include the last character"
3944
3944
) ;
3945
+ // SAFETY: `Searcher` is known to return valid indices.
3945
3946
unsafe {
3946
- // Searcher is known to return valid indices.
3947
3947
Some ( self . get_unchecked ( ..start) )
3948
3948
}
3949
3949
} else {
@@ -4381,8 +4381,8 @@ impl Default for &str {
4381
4381
#[ stable( feature = "default_mut_str" , since = "1.28.0" ) ]
4382
4382
impl Default for & mut str {
4383
4383
/// Creates an empty mutable str
4384
- // SAFETY: `str` is guranteed to be UTF-8.
4385
4384
fn default ( ) -> Self {
4385
+ // SAFETY: The empty string is valid UTF-8.
4386
4386
unsafe { from_utf8_unchecked_mut ( & mut [ ] ) }
4387
4387
}
4388
4388
}
0 commit comments