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] {
514
514
}
515
515
}
516
516
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
+
517
524
impl < ' a > From < & ' a AsciiStr > for & ' a [ AsciiChar ] {
518
525
#[ inline]
519
526
fn from ( astr : & AsciiStr ) -> & [ AsciiChar ] {
@@ -1493,10 +1500,9 @@ mod tests {
1493
1500
#[ test]
1494
1501
#[ cfg( feature = "alloc" ) ]
1495
1502
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 ( ) ;
1498
1504
unsafe {
1499
- let converted = boxed . into_boxed_bytes ( ) ;
1505
+ let converted = s . clone ( ) . into_boxed_bytes ( ) ;
1500
1506
assert_eq ! ( & converted[ ..] , & b"abc" [ ..] ) ;
1501
1507
let converted_back = AsciiStr :: from_boxed_ascii_bytes_unchecked ( converted) ;
1502
1508
assert_eq ! ( & converted_back[ ..] , & s[ ..] ) ;
You can’t perform that action at this time.
0 commit comments