about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-06-18 15:48:00 -0700
committerCorey Farwell <coreyf@rwell.org>2017-06-20 13:49:27 -0400
commit65793b30d35273c57767714ddf61e0360c64dea1 (patch)
tree57a72973e5a44ca62cc446aa8393827229ab5dcb /src/libstd
parentdb971451506763b860575786e5c391b6a1b149c5 (diff)
Add doc example for `Box<CStr>::into_c_string`.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/ffi/c_str.rs12
1 files changed, 12 insertions, 0 deletions
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<CStr>) -> CString {
         unsafe { mem::transmute(self) }