File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -445,6 +445,13 @@ impl AsRef<AsciiStr> for AsciiString {
445
445
}
446
446
}
447
447
448
+ impl AsRef < [ u8 ] > for AsciiString {
449
+ #[ inline]
450
+ fn as_ref ( & self ) -> & [ u8 ] {
451
+ self . as_bytes ( )
452
+ }
453
+ }
454
+
448
455
impl AsMut < AsciiStr > for AsciiString {
449
456
#[ inline]
450
457
fn as_mut ( & mut self ) -> & mut AsciiStr {
Original file line number Diff line number Diff line change @@ -33,7 +33,8 @@ fn into_ascii() {
33
33
let arr = [ AsciiChar :: ParenOpen , AsciiChar :: Space , AsciiChar :: Semicolon ] ;
34
34
let v = AsciiString :: from ( arr. to_vec ( ) ) ;
35
35
assert_eq ! ( b"( ;" . to_vec( ) . into_ascii_string( ) , Ok ( v. clone( ) ) ) ;
36
- assert_eq ! ( "( ;" . to_string( ) . into_ascii_string( ) , Ok ( v) ) ;
36
+ assert_eq ! ( "( ;" . to_string( ) . into_ascii_string( ) , Ok ( v. clone( ) ) ) ;
37
+ assert_eq ! ( b"( ;" , AsRef :: <[ u8 ] >:: as_ref( & v) ) ;
37
38
38
39
let err = "zoä华" . to_string ( ) . into_ascii_string ( ) . unwrap_err ( ) ;
39
40
assert_eq ! ( Err ( err. ascii_error( ) ) , "zoä华" . as_ascii_str( ) ) ;
You can’t perform that action at this time.
0 commit comments