about summary refs log tree commit diff
path: root/src/libstd/ffi
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-06-18 17:31:06 -0700
committerCorey Farwell <coreyf@rwell.org>2017-06-20 13:49:42 -0400
commit4797d8446c73eb8ca96d29aec336787f719a071c (patch)
tree275b7a2f2ec07b1eba523915d60449fac7535570 /src/libstd/ffi
parente52d2f2ad0e0df9c2be02bc7bf99dd2324c78fd2 (diff)
downloadrust-4797d8446c73eb8ca96d29aec336787f719a071c.tar.gz
rust-4797d8446c73eb8ca96d29aec336787f719a071c.zip
Add doc example for `NulError`.
Diffstat (limited to 'src/libstd/ffi')
-rw-r--r--src/libstd/ffi/c_str.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs
index 8a7757fde88..bedd5f524c7 100644
--- a/src/libstd/ffi/c_str.rs
+++ b/src/libstd/ffi/c_str.rs
@@ -152,6 +152,14 @@ pub struct CStr {
 /// in the vector provided.
 ///
 /// [`CString::new`]: struct.CString.html#method.new
+///
+/// # Examples
+///
+/// ```
+/// use std::ffi::{CString, NulError};
+///
+/// let _: NulError = CString::new(b"f\0oo".to_vec()).unwrap_err();
+/// ```
 #[derive(Clone, PartialEq, Eq, Debug)]
 #[stable(feature = "rust1", since = "1.0.0")]
 pub struct NulError(usize, Vec<u8>);