@@ -7,7 +7,9 @@ use alloc::string::String;
7
7
use alloc:: string:: ToString ;
8
8
use alloc:: vec:: Vec ;
9
9
use core:: fmt:: { self , Display } ;
10
+ use core:: hint;
10
11
use core:: num:: FpCategory ;
12
+ use core:: str;
11
13
use serde:: ser:: { self , Impossible , Serialize } ;
12
14
13
15
/// A structure for serializing Rust values into JSON.
@@ -2100,8 +2102,8 @@ where
2100
2102
bytes = rest;
2101
2103
i = 0 ;
2102
2104
2103
- // safety : string_run is a valid utf8 string, since we only split on ascii sequences
2104
- let string_run = unsafe { core :: str:: from_utf8_unchecked ( string_run) } ;
2105
+ // Safety : string_run is a valid utf8 string, since we only split on ascii sequences
2106
+ let string_run = unsafe { str:: from_utf8_unchecked ( string_run) } ;
2105
2107
if !string_run. is_empty ( ) {
2106
2108
tri ! ( formatter. write_string_fragment( writer, string_run) ) ;
2107
2109
}
@@ -2115,14 +2117,14 @@ where
2115
2117
self :: QU => CharEscape :: Quote ,
2116
2118
self :: BS => CharEscape :: ReverseSolidus ,
2117
2119
self :: UU => CharEscape :: AsciiControl ( byte) ,
2118
- // safety : the escape table does not contain any other type of character.
2119
- _ => unsafe { core :: hint:: unreachable_unchecked ( ) } ,
2120
+ // Safety : the escape table does not contain any other type of character.
2121
+ _ => unsafe { hint:: unreachable_unchecked ( ) } ,
2120
2122
} ;
2121
2123
tri ! ( formatter. write_char_escape( writer, char_escape) ) ;
2122
2124
}
2123
2125
2124
- // safety : bytes is a valid utf8 string, since we only split on ascii sequences
2125
- let string_run = unsafe { core :: str:: from_utf8_unchecked ( bytes) } ;
2126
+ // Safety : bytes is a valid utf8 string, since we only split on ascii sequences
2127
+ let string_run = unsafe { str:: from_utf8_unchecked ( bytes) } ;
2126
2128
if string_run. is_empty ( ) {
2127
2129
return Ok ( ( ) ) ;
2128
2130
}
0 commit comments