@@ -15,6 +15,8 @@ use std::ffi::{CStr, CString};
1515
1616use ascii_char:: AsciiChar ;
1717use ascii_str:: { AsAsciiStr , AsAsciiStrError , AsciiStr } ;
18+ use std:: rc:: Rc ;
19+ use std:: sync:: Arc ;
1820
1921/// A growable string stored as an ASCII encoded buffer.
2022#[ derive( Clone , Default , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
@@ -513,6 +515,12 @@ impl Into<Vec<u8>> for AsciiString {
513515 }
514516}
515517
518+ impl Into < Vec < AsciiChar > > for AsciiString {
519+ fn into ( self ) -> Vec < AsciiChar > {
520+ self . vec
521+ }
522+ }
523+
516524impl < ' a > From < & ' a AsciiStr > for AsciiString {
517525 #[ inline]
518526 fn from ( s : & ' a AsciiStr ) -> Self {
@@ -553,6 +561,22 @@ impl From<AsciiString> for Box<AsciiStr> {
553561 }
554562}
555563
564+ impl Into < Rc < AsciiStr > > for AsciiString {
565+ fn into ( self ) -> Rc < AsciiStr > {
566+ let var: Rc < [ AsciiChar ] > = self . vec . into ( ) ;
567+ // SAFETY: AsciiStr is repr(transparent) and thus has the same layout as [AsciiChar]
568+ unsafe { Rc :: from_raw ( Rc :: into_raw ( var) as * const AsciiStr ) }
569+ }
570+ }
571+
572+ impl Into < Arc < AsciiStr > > for AsciiString {
573+ fn into ( self ) -> Arc < AsciiStr > {
574+ let var: Arc < [ AsciiChar ] > = self . vec . into ( ) ;
575+ // SAFETY: AsciiStr is repr(transparent) and thus has the same layout as [AsciiChar]
576+ unsafe { Arc :: from_raw ( Arc :: into_raw ( var) as * const AsciiStr ) }
577+ }
578+ }
579+
556580impl < ' a > From < Cow < ' a , AsciiStr > > for AsciiString {
557581 fn from ( cow : Cow < ' a , AsciiStr > ) -> AsciiString {
558582 cow. into_owned ( )
0 commit comments