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 @@ -452,6 +452,13 @@ impl AsMut<AsciiStr> for [AsciiChar] {
452452 }
453453}
454454
455+ #[ cfg( feature = "alloc" ) ]
456+ impl Clone for Box < AsciiStr > {
457+ fn clone ( & self ) -> Box < AsciiStr > {
458+ self . to_ascii_string ( ) . into ( )
459+ }
460+ }
461+
455462impl < ' a > From < & ' a AsciiStr > for & ' a [ AsciiChar ] {
456463 #[ inline]
457464 fn from ( astr : & AsciiStr ) -> & [ AsciiChar ] {
@@ -1431,10 +1438,9 @@ mod tests {
14311438 #[ test]
14321439 #[ cfg( feature = "alloc" ) ]
14331440 fn to_and_from_byte_box ( ) {
1434- let s = "abc" . as_ascii_str ( ) . unwrap ( ) . to_ascii_string ( ) ;
1435- let boxed = s. clone ( ) . into_boxed_ascii_str ( ) ;
1441+ let s = "abc" . as_ascii_str ( ) . unwrap ( ) . to_ascii_string ( ) . into_boxed_ascii_str ( ) ;
14361442 unsafe {
1437- let converted = boxed . into_boxed_bytes ( ) ;
1443+ let converted = s . clone ( ) . into_boxed_bytes ( ) ;
14381444 assert_eq ! ( & converted[ ..] , & b"abc" [ ..] ) ;
14391445 let converted_back = AsciiStr :: from_boxed_ascii_bytes_unchecked ( converted) ;
14401446 assert_eq ! ( & converted_back[ ..] , & s[ ..] ) ;
You can’t perform that action at this time.
0 commit comments