]> git.lizzy.rs Git - rust.git/commitdiff
Add doc example for `std::ffi::NulError::into_vec`.
authorCorey Farwell <coreyf@rwell.org>
Sat, 6 Aug 2016 21:50:37 +0000 (17:50 -0400)
committerCorey Farwell <coreyf@rwell.org>
Sat, 6 Aug 2016 21:50:37 +0000 (17:50 -0400)
src/libstd/ffi/c_str.rs

index f800a6e228e9ba0f96bcf56f20e4ef63964cb3e8..e0501f9cc61d24c70781bab1cf2645d2ed143ffe 100644 (file)
@@ -373,6 +373,15 @@ pub fn nul_position(&self) -> usize { self.0 }
 
     /// 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 }
 }