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