File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -935,20 +935,24 @@ impl fmt::Display for NodeAlias {
935
935
let control_symbol = core:: char:: REPLACEMENT_CHARACTER ;
936
936
let first_null = self . 0 . iter ( ) . position ( |b| * b == 0 ) . unwrap_or ( self . 0 . len ( ) ) ;
937
937
let bytes = self . 0 . split_at ( first_null) . 0 ;
938
- let alias = match core:: str:: from_utf8 ( bytes) {
938
+ match core:: str:: from_utf8 ( bytes) {
939
939
Ok ( alias) => {
940
- alias. chars ( )
941
- . map ( |c| if c. is_control ( ) { control_symbol } else { c } )
942
- . collect :: < String > ( )
940
+ for c in alias. chars ( ) {
941
+ let mut bytes = [ 0u8 ; 4 ] ;
942
+ let c = if !c. is_control ( ) { c } else { control_symbol } ;
943
+ f. write_str ( c. encode_utf8 ( & mut bytes) ) ?;
944
+ }
943
945
} ,
944
946
Err ( _) => {
945
- bytes. iter ( ) . map ( |b| * b as char )
947
+ for c in bytes. iter ( ) . map ( |b| * b as char ) {
946
948
// Display printable ASCII characters
947
- . map ( |c| if c >= '\x20' && c <= '\x7e' { c } else { control_symbol } )
948
- . collect :: < String > ( )
949
+ let mut bytes = [ 0u8 ; 4 ] ;
950
+ let c = if c >= '\x20' && c <= '\x7e' { c } else { control_symbol } ;
951
+ f. write_str ( c. encode_utf8 ( & mut bytes) ) ?;
952
+ }
949
953
} ,
950
954
} ;
951
- f . write_str ( & alias )
955
+ Ok ( ( ) )
952
956
}
953
957
}
954
958
You can’t perform that action at this time.
0 commit comments