@@ -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 ) ]
@@ -513,6 +515,12 @@ impl Into<Vec<u8>> for AsciiString {
513
515
}
514
516
}
515
517
518
+ impl Into < Vec < AsciiChar > > for AsciiString {
519
+ fn into ( self ) -> Vec < AsciiChar > {
520
+ self . vec
521
+ }
522
+ }
523
+
516
524
impl < ' a > From < & ' a AsciiStr > for AsciiString {
517
525
#[ inline]
518
526
fn from ( s : & ' a AsciiStr ) -> Self {
@@ -553,6 +561,22 @@ impl From<AsciiString> for Box<AsciiStr> {
553
561
}
554
562
}
555
563
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
+
556
580
impl < ' a > From < Cow < ' a , AsciiStr > > for AsciiString {
557
581
fn from ( cow : Cow < ' a , AsciiStr > ) -> AsciiString {
558
582
cow. into_owned ( )
0 commit comments