File tree 1 file changed +10
-6
lines changed
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -238,11 +238,7 @@ impl<const N: usize> Debug for Bytes<N> {
238
238
use core:: ascii:: escape_default;
239
239
f. write_str ( "b'" ) ?;
240
240
for byte in & self . bytes {
241
- for ch in escape_default ( * byte) {
242
- // Debug::fmt(unsafe { core::str::from_utf8_unchecked(&[ch]) }, f)?;
243
- f. write_str ( unsafe { core:: str:: from_utf8_unchecked ( & [ ch] ) } ) ?;
244
- // f.write(&ch);
245
- }
241
+ write ! ( f, "{}" , escape_default( * byte) ) ?;
246
242
}
247
243
f. write_str ( "'" ) ?;
248
244
Ok ( ( ) )
@@ -395,7 +391,7 @@ mod tests_serde {
395
391
use serde_test:: { assert_tokens, Token } ;
396
392
397
393
#[ test]
398
- fn all ( ) {
394
+ fn serde ( ) {
399
395
let mut bytes = Bytes :: < 0 > :: new ( ) ;
400
396
assert ! ( bytes. push( 1 ) . is_err( ) ) ;
401
397
assert_tokens ( & bytes, & [ Token :: Bytes ( & [ ] ) ] ) ;
@@ -414,6 +410,14 @@ mod tests_serde {
414
410
] ) ] ,
415
411
) ;
416
412
}
413
+
414
+ #[ test]
415
+ fn display ( ) {
416
+ assert_eq ! (
417
+ r"b'\x00abcde\n'" ,
418
+ format!( "{:?}" , Bytes :: <10 >:: from_slice( b"\0 abcde\n " ) . unwrap( ) )
419
+ ) ;
420
+ }
417
421
}
418
422
419
423
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments