]> git.lizzy.rs Git - rust.git/commitdiff
Add doc example for `FromBytesWithNulError`.
authorCorey Farwell <coreyf@rwell.org>
Mon, 19 Jun 2017 00:44:41 +0000 (17:44 -0700)
committerCorey Farwell <coreyf@rwell.org>
Tue, 20 Jun 2017 17:49:42 +0000 (13:49 -0400)
src/libstd/ffi/c_str.rs

index bedd5f524c7898c9dea909d716a25134b7d6a593..ca7cd37a88d7c51c014b611356b749b046e072cc 100644 (file)
@@ -168,6 +168,14 @@ pub struct CStr {
 /// byte was found too early in the slice provided or one wasn't found at all.
 ///
 /// [`CStr::from_bytes_with_nul`]: struct.CStr.html#method.from_bytes_with_nul
+///
+/// # Examples
+///
+/// ```
+/// use std::ffi::{CStr, FromBytesWithNulError};
+///
+/// let _: FromBytesWithNulError = CStr::from_bytes_with_nul(b"f\0oo").unwrap_err();
+/// ```
 #[derive(Clone, PartialEq, Eq, Debug)]
 #[stable(feature = "cstr_from_bytes", since = "1.10.0")]
 pub struct FromBytesWithNulError {