We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
Box<CStr>::into_c_string
1 parent db97145 commit 65793b3Copy full SHA for 65793b3
src/libstd/ffi/c_str.rs
@@ -939,6 +939,18 @@ impl CStr {
939
///
940
/// [`Box`]: ../boxed/struct.Box.html
941
/// [`CString`]: struct.CString.html
942
+ ///
943
+ /// # Examples
944
945
+ /// ```
946
+ /// #![feature(into_boxed_c_str)]
947
948
+ /// use std::ffi::CString;
949
950
+ /// let c_string = CString::new(b"foo".to_vec()).unwrap();
951
+ /// let boxed = c_string.into_boxed_c_str();
952
+ /// assert_eq!(boxed.into_c_string(), CString::new("foo").unwrap());
953
954
#[unstable(feature = "into_boxed_c_str", issue = "40380")]
955
pub fn into_c_string(self: Box<CStr>) -> CString {
956
unsafe { mem::transmute(self) }
0 commit comments