File tree 1 file changed +9
-3
lines changed
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] {
452
452
}
453
453
}
454
454
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
+
455
462
impl < ' a > From < & ' a AsciiStr > for & ' a [ AsciiChar ] {
456
463
#[ inline]
457
464
fn from ( astr : & AsciiStr ) -> & [ AsciiChar ] {
@@ -1431,10 +1438,9 @@ mod tests {
1431
1438
#[ test]
1432
1439
#[ cfg( feature = "alloc" ) ]
1433
1440
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 ( ) ;
1436
1442
unsafe {
1437
- let converted = boxed . into_boxed_bytes ( ) ;
1443
+ let converted = s . clone ( ) . into_boxed_bytes ( ) ;
1438
1444
assert_eq ! ( & converted[ ..] , & b"abc" [ ..] ) ;
1439
1445
let converted_back = AsciiStr :: from_boxed_ascii_bytes_unchecked ( converted) ;
1440
1446
assert_eq ! ( & converted_back[ ..] , & s[ ..] ) ;
You can’t perform that action at this time.
0 commit comments