From 65793b30d35273c57767714ddf61e0360c64dea1 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sun, 18 Jun 2017 15:48:00 -0700 Subject: [PATCH] Add doc example for `Box::into_c_string`. --- src/libstd/ffi/c_str.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index b84b4d6dd7d..b94a34b054c 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) }