diff options
| author | bors <bors@rust-lang.org> | 2016-08-05 07:37:16 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-08-05 07:37:16 -0700 |
| commit | b30eff7ba72a78e31acd61a2b6931919a0ad62e8 (patch) | |
| tree | 7261c377c72620cd6cd3d668cdbb7a7236469d58 /src/libstd/ffi | |
| parent | 4c02363852e6ce41cf2da1b43a32cb7780a9b067 (diff) | |
| parent | cd48161e2ca866ef05a076181225cb041c679994 (diff) | |
Auto merge of #35365 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 30 pull requests - Successful merges: #34319, #35041, #35042, #35076, #35109, #35137, #35175, #35181, #35182, #35189, #35239, #35264, #35266, #35281, #35285, #35289, #35291, #35294, #35296, #35297, #35298, #35299, #35318, #35319, #35324, #35326, #35328, #35333, #35359, #35362 - Failed merges:
Diffstat (limited to 'src/libstd/ffi')
| -rw-r--r-- | src/libstd/ffi/c_str.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index 0d3e18f9b96..f800a6e228e 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -356,6 +356,18 @@ impl Borrow<CStr> for CString { impl NulError { /// Returns the position of the nul byte in the slice that was provided to /// `CString::new`. + /// + /// # Examples + /// + /// ``` + /// use std::ffi::CString; + /// + /// let nul_error = CString::new("foo\0bar").unwrap_err(); + /// assert_eq!(nul_error.nul_position(), 3); + /// + /// let nul_error = CString::new("foo bar\0").unwrap_err(); + /// assert_eq!(nul_error.nul_position(), 7); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn nul_position(&self) -> usize { self.0 } |
