From 0a6b862ccd428e317f1cfc65213fbedc0c4e5e05 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Sat, 6 Aug 2016 17:50:37 -0400 Subject: [PATCH] Add doc example for `std::ffi::NulError::into_vec`. --- src/libstd/ffi/c_str.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index f800a6e228e9b..e0501f9cc61d2 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 { self.1 } }