File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -514,6 +514,13 @@ impl AsMut<AsciiStr> for [AsciiChar] {
514514 }
515515}
516516
517+ #[ cfg( feature = "alloc" ) ]
518+ impl Clone for Box < AsciiStr > {
519+ fn clone ( & self ) -> Box < AsciiStr > {
520+ self . to_ascii_string ( ) . into ( )
521+ }
522+ }
523+
517524impl < ' a > From < & ' a AsciiStr > for & ' a [ AsciiChar ] {
518525 #[ inline]
519526 fn from ( astr : & AsciiStr ) -> & [ AsciiChar ] {
@@ -1493,10 +1500,9 @@ mod tests {
14931500 #[ test]
14941501 #[ cfg( feature = "alloc" ) ]
14951502 fn to_and_from_byte_box ( ) {
1496- let s = "abc" . as_ascii_str ( ) . unwrap ( ) . to_ascii_string ( ) ;
1497- let boxed = s. clone ( ) . into_boxed_ascii_str ( ) ;
1503+ let s = "abc" . as_ascii_str ( ) . unwrap ( ) . to_ascii_string ( ) . into_boxed_ascii_str ( ) ;
14981504 unsafe {
1499- let converted = boxed . into_boxed_bytes ( ) ;
1505+ let converted = s . clone ( ) . into_boxed_bytes ( ) ;
15001506 assert_eq ! ( & converted[ ..] , & b"abc" [ ..] ) ;
15011507 let converted_back = AsciiStr :: from_boxed_ascii_bytes_unchecked ( converted) ;
15021508 assert_eq ! ( & converted_back[ ..] , & s[ ..] ) ;
You can’t perform that action at this time.
0 commit comments