Skip to content

Commit d3c26fe

Browse files
committed
Add doc example for FromBytesWithNulError.
1 parent 4797d84 commit d3c26fe

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/libstd/ffi/c_str.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,14 @@ pub struct NulError(usize, Vec<u8>);
168168
/// byte was found too early in the slice provided or one wasn't found at all.
169169
///
170170
/// [`CStr::from_bytes_with_nul`]: struct.CStr.html#method.from_bytes_with_nul
171+
///
172+
/// # Examples
173+
///
174+
/// ```
175+
/// use std::ffi::{CStr, FromBytesWithNulError};
176+
///
177+
/// let _: FromBytesWithNulError = CStr::from_bytes_with_nul(b"f\0oo").unwrap_err();
178+
/// ```
171179
#[derive(Clone, PartialEq, Eq, Debug)]
172180
#[stable(feature = "cstr_from_bytes", since = "1.10.0")]
173181
pub struct FromBytesWithNulError {

0 commit comments

Comments
 (0)