Skip to content

Commit 0a6b862

Browse files
committed
Add doc example for std::ffi::NulError::into_vec.
1 parent 444ff9f commit 0a6b862

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/libstd/ffi/c_str.rs

+9
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,15 @@ impl NulError {
373373

374374
/// Consumes this error, returning the underlying vector of bytes which
375375
/// generated the error in the first place.
376+
///
377+
/// # Examples
378+
///
379+
/// ```
380+
/// use std::ffi::CString;
381+
///
382+
/// let nul_error = CString::new("foo\0bar").unwrap_err();
383+
/// assert_eq!(nul_error.into_vec(), b"foo\0bar");
384+
/// ```
376385
#[stable(feature = "rust1", since = "1.0.0")]
377386
pub fn into_vec(self) -> Vec<u8> { self.1 }
378387
}

0 commit comments

Comments
 (0)