@@ -15,6 +15,8 @@ use std::ffi::{CStr, CString};
15
15
16
16
use ascii_char:: AsciiChar ;
17
17
use ascii_str:: { AsAsciiStr , AsAsciiStrError , AsciiStr } ;
18
+ use std:: rc:: Rc ;
19
+ use std:: sync:: Arc ;
18
20
19
21
/// A growable string stored as an ASCII encoded buffer.
20
22
#[ derive( Clone , Default , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
@@ -474,6 +476,12 @@ impl Into<Vec<u8>> for AsciiString {
474
476
}
475
477
}
476
478
479
+ impl Into < Vec < AsciiChar > > for AsciiString {
480
+ fn into ( self ) -> Vec < AsciiChar > {
481
+ self . vec
482
+ }
483
+ }
484
+
477
485
impl < ' a > From < & ' a AsciiStr > for AsciiString {
478
486
#[ inline]
479
487
fn from ( s : & ' a AsciiStr ) -> Self {
@@ -496,6 +504,22 @@ impl Into<String> for AsciiString {
496
504
}
497
505
}
498
506
507
+ impl Into < Rc < AsciiStr > > for AsciiString {
508
+ fn into ( self ) -> Rc < AsciiStr > {
509
+ let var: Rc < [ AsciiChar ] > = self . vec . into ( ) ;
510
+ // SAFETY: AsciiStr is repr(transparent) and thus has the same layout as [AsciiChar]
511
+ unsafe { Rc :: from_raw ( Rc :: into_raw ( var) as * const AsciiStr ) }
512
+ }
513
+ }
514
+
515
+ impl Into < Arc < AsciiStr > > for AsciiString {
516
+ fn into ( self ) -> Arc < AsciiStr > {
517
+ let var: Arc < [ AsciiChar ] > = self . vec . into ( ) ;
518
+ // SAFETY: AsciiStr is repr(transparent) and thus has the same layout as [AsciiChar]
519
+ unsafe { Arc :: from_raw ( Arc :: into_raw ( var) as * const AsciiStr ) }
520
+ }
521
+ }
522
+
499
523
impl < ' a > From < Cow < ' a , AsciiStr > > for AsciiString {
500
524
fn from ( cow : Cow < ' a , AsciiStr > ) -> AsciiString {
501
525
cow. into_owned ( )
0 commit comments