about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2016-08-06 17:50:37 -0400
committerCorey Farwell <coreyf@rwell.org>2016-08-06 17:50:37 -0400
commit0a6b862ccd428e317f1cfc65213fbedc0c4e5e05 (patch)
tree70903dfbc6a529c0810ca61f34fc2b9a27236db9 /src/libstd
parent444ff9fbfb1f2a8e6645f67684f8a9ad99b343d3 (diff)
downloadrust-0a6b862ccd428e317f1cfc65213fbedc0c4e5e05.tar.gz
rust-0a6b862ccd428e317f1cfc65213fbedc0c4e5e05.zip
Add doc example for `std::ffi::NulError::into_vec`.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/ffi/c_str.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs
index f800a6e228e..e0501f9cc61 100644
--- a/src/libstd/ffi/c_str.rs
+++ b/src/libstd/ffi/c_str.rs
@@ -373,6 +373,15 @@ impl NulError {
 
     /// Consumes this error, returning the underlying vector of bytes which
     /// generated the error in the first place.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// use std::ffi::CString;
+    ///
+    /// let nul_error = CString::new("foo\0bar").unwrap_err();
+    /// assert_eq!(nul_error.into_vec(), b"foo\0bar");
+    /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
     pub fn into_vec(self) -> Vec<u8> { self.1 }
 }