diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index b84b4d6dd7d1b..b94a34b054c57 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -939,6 +939,18 @@ impl CStr { /// /// [`Box`]: ../boxed/struct.Box.html /// [`CString`]: struct.CString.html + /// + /// # Examples + /// + /// ``` + /// #![feature(into_boxed_c_str)] + /// + /// use std::ffi::CString; + /// + /// let c_string = CString::new(b"foo".to_vec()).unwrap(); + /// let boxed = c_string.into_boxed_c_str(); + /// assert_eq!(boxed.into_c_string(), CString::new("foo").unwrap()); + /// ``` #[unstable(feature = "into_boxed_c_str", issue = "40380")] pub fn into_c_string(self: Box) -> CString { unsafe { mem::transmute(self) }