@@ -642,6 +642,12 @@ impl fmt::Debug for CString {
642
642
643
643
#[ stable( feature = "cstring_into" , since = "1.7.0" ) ]
644
644
impl From < CString > for Vec < u8 > {
645
+ /// Converts a [`CString`] into a [`Vec`]`<u8>`.
646
+ ///
647
+ /// The conversion consumes the [`CString`], and removes the terminating NUL byte.
648
+ ///
649
+ /// [`Vec`]: ../vec/struct.Vec.html
650
+ /// [`CString`]: ../ffi/struct.CString.html
645
651
#[ inline]
646
652
fn from ( s : CString ) -> Vec < u8 > {
647
653
s. into_bytes ( )
@@ -700,6 +706,10 @@ impl<'a> From<&'a CStr> for Box<CStr> {
700
706
701
707
#[ stable( feature = "c_string_from_box" , since = "1.18.0" ) ]
702
708
impl From < Box < CStr > > for CString {
709
+ /// Converts a [`Box`]`<CStr>` into a [`CString`] without copying or allocating.
710
+ ///
711
+ /// [`Box`]: ../boxed/struct.Box.html
712
+ /// [`CString`]: ../ffi/struct.CString.html
703
713
#[ inline]
704
714
fn from ( s : Box < CStr > ) -> CString {
705
715
s. into_c_string ( )
@@ -716,6 +726,10 @@ impl Clone for Box<CStr> {
716
726
717
727
#[ stable( feature = "box_from_c_string" , since = "1.20.0" ) ]
718
728
impl From < CString > for Box < CStr > {
729
+ /// Converts a [`CString`] into a [`Box`]`<CStr>` without copying or allocating.
730
+ ///
731
+ /// [`CString`]: ../ffi/struct.CString.html
732
+ /// [`Box`]: ../boxed/struct.Box.html
719
733
#[ inline]
720
734
fn from ( s : CString ) -> Box < CStr > {
721
735
s. into_boxed_c_str ( )
@@ -748,6 +762,10 @@ impl<'a> From<&'a CString> for Cow<'a, CStr> {
748
762
749
763
#[ stable( feature = "shared_from_slice2" , since = "1.24.0" ) ]
750
764
impl From < CString > for Arc < CStr > {
765
+ /// Converts a [`CString`] into a [`Arc`]`<CStr>` without copying or allocating.
766
+ ///
767
+ /// [`CString`]: ../ffi/struct.CString.html
768
+ /// [`Arc`]: ../sync/struct.Arc.html
751
769
#[ inline]
752
770
fn from ( s : CString ) -> Arc < CStr > {
753
771
let arc: Arc < [ u8 ] > = Arc :: from ( s. into_inner ( ) ) ;
@@ -766,6 +784,10 @@ impl<'a> From<&'a CStr> for Arc<CStr> {
766
784
767
785
#[ stable( feature = "shared_from_slice2" , since = "1.24.0" ) ]
768
786
impl From < CString > for Rc < CStr > {
787
+ /// Converts a [`CString`] into a [`Rc`]`<CStr>` without copying or allocating.
788
+ ///
789
+ /// [`CString`]: ../ffi/struct.CString.html
790
+ /// [`Rc`]: ../rc/struct.Rc.html
769
791
#[ inline]
770
792
fn from ( s : CString ) -> Rc < CStr > {
771
793
let rc: Rc < [ u8 ] > = Rc :: from ( s. into_inner ( ) ) ;
@@ -839,6 +861,10 @@ impl fmt::Display for NulError {
839
861
840
862
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
841
863
impl From < NulError > for io:: Error {
864
+ /// Converts a [`NulError`] into a [`io::Error`].
865
+ ///
866
+ /// [`NulError`]: ../ffi/struct.NulError.html
867
+ /// [`io::Error`]: ../io/struct.Error.html
842
868
fn from ( _: NulError ) -> io:: Error {
843
869
io:: Error :: new ( io:: ErrorKind :: InvalidInput ,
844
870
"data provided contains a nul byte" )
0 commit comments