1919// implementations, so, we'll have to add more doc(hidden)s anyway
2020#![ doc( hidden) ]
2121
22- use crate :: char:: encode_utf16_raw;
22+ use crate :: char:: { EscapeDebugExtArgs , encode_utf16_raw} ;
2323use crate :: clone:: CloneToUninit ;
2424use crate :: fmt:: { self , Write } ;
2525use crate :: hash:: { Hash , Hasher } ;
@@ -144,14 +144,20 @@ impl AsRef<[u8]> for Wtf8 {
144144impl fmt:: Debug for Wtf8 {
145145 fn fmt ( & self , formatter : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
146146 fn write_str_escaped ( f : & mut fmt:: Formatter < ' _ > , s : & str ) -> fmt:: Result {
147- use crate :: fmt:: Write ;
148- for c in s. chars ( ) . flat_map ( |c| c. escape_debug ( ) ) {
147+ use crate :: fmt:: Write as _;
148+ for c in s. chars ( ) . flat_map ( |c| {
149+ c. escape_debug_ext ( EscapeDebugExtArgs {
150+ escape_grapheme_extended : true ,
151+ escape_single_quote : false ,
152+ escape_double_quote : true ,
153+ } )
154+ } ) {
149155 f. write_char ( c) ?
150156 }
151157 Ok ( ( ) )
152158 }
153159
154- formatter. write_str ( " \" " ) ?;
160+ formatter. write_char ( '"' ) ?;
155161 let mut pos = 0 ;
156162 while let Some ( ( surrogate_pos, surrogate) ) = self . next_surrogate ( pos) {
157163 // SAFETY: next_surrogate provides an index for a range of valid UTF-8 bytes.
@@ -164,7 +170,7 @@ impl fmt::Debug for Wtf8 {
164170
165171 // SAFETY: after next_surrogate returns None, the remainder is valid UTF-8.
166172 write_str_escaped ( formatter, unsafe { str:: from_utf8_unchecked ( & self . bytes [ pos..] ) } ) ?;
167- formatter. write_str ( " \" " )
173+ formatter. write_char ( '"' )
168174 }
169175}
170176
0 commit comments