@@ -682,6 +682,14 @@ impl Borrow<CStr> for CString {
682
682
fn borrow ( & self ) -> & CStr { self }
683
683
}
684
684
685
+ #[ stable( feature = "cstring_from_cow_cstr" , since = "1.28.0" ) ]
686
+ impl < ' a > From < Cow < ' a , CStr > > for CString {
687
+ #[ inline]
688
+ fn from ( s : Cow < ' a , CStr > ) -> Self {
689
+ s. into_owned ( )
690
+ }
691
+ }
692
+
685
693
#[ stable( feature = "box_from_c_str" , since = "1.17.0" ) ]
686
694
impl < ' a > From < & ' a CStr > for Box < CStr > {
687
695
fn from ( s : & ' a CStr ) -> Box < CStr > {
@@ -706,6 +714,30 @@ impl From<CString> for Box<CStr> {
706
714
}
707
715
}
708
716
717
+ #[ stable( feature = "cow_from_cstr" , since = "1.28.0" ) ]
718
+ impl < ' a > From < CString > for Cow < ' a , CStr > {
719
+ #[ inline]
720
+ fn from ( s : CString ) -> Cow < ' a , CStr > {
721
+ Cow :: Owned ( s)
722
+ }
723
+ }
724
+
725
+ #[ stable( feature = "cow_from_cstr" , since = "1.28.0" ) ]
726
+ impl < ' a > From < & ' a CStr > for Cow < ' a , CStr > {
727
+ #[ inline]
728
+ fn from ( s : & ' a CStr ) -> Cow < ' a , CStr > {
729
+ Cow :: Borrowed ( s)
730
+ }
731
+ }
732
+
733
+ #[ stable( feature = "cow_from_cstr" , since = "1.28.0" ) ]
734
+ impl < ' a > From < & ' a CString > for Cow < ' a , CStr > {
735
+ #[ inline]
736
+ fn from ( s : & ' a CString ) -> Cow < ' a , CStr > {
737
+ Cow :: Borrowed ( s. as_c_str ( ) )
738
+ }
739
+ }
740
+
709
741
#[ stable( feature = "shared_from_slice2" , since = "1.24.0" ) ]
710
742
impl From < CString > for Arc < CStr > {
711
743
#[ inline]
0 commit comments