File tree Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Expand file tree Collapse file tree 1 file changed +3
-6
lines changed Original file line number Diff line number Diff line change @@ -2421,12 +2421,8 @@ impl Debug for str {
2421
2421
// SAFETY: the position was derived from an iterator, so is known to be within bounds, and at a char boundary
2422
2422
rest = unsafe { rest. get_unchecked ( non_printable_start..) } ;
2423
2423
2424
- let printable_start =
2425
- rest. as_bytes ( ) . iter ( ) . position ( |& b| !needs_escape ( b) ) . unwrap_or ( rest. len ( ) ) ;
2426
- let prefix;
2427
- ( prefix, rest) = rest. split_at ( printable_start) ;
2428
-
2429
- for c in prefix. chars ( ) {
2424
+ let mut chars = rest. chars ( ) ;
2425
+ if let Some ( c) = chars. next ( ) {
2430
2426
let esc = c. escape_debug_ext ( EscapeDebugExtArgs {
2431
2427
escape_grapheme_extended : true ,
2432
2428
escape_single_quote : false ,
@@ -2439,6 +2435,7 @@ impl Debug for str {
2439
2435
}
2440
2436
printable_range. end += c. len_utf8 ( ) ;
2441
2437
}
2438
+ rest = chars. as_str ( ) ;
2442
2439
}
2443
2440
2444
2441
f. write_str ( & self [ printable_range] ) ?;
You can’t perform that action at this time.
0 commit comments