diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-06-18 14:12:17 -0700 |
|---|---|---|
| committer | Corey Farwell <coreyf@rwell.org> | 2017-06-20 13:49:27 -0400 |
| commit | 7f687f8602e1d3d8290c154ec67bb8fbd5f493d7 (patch) | |
| tree | e9fb52b1a7412c75aaaee0df8f1e7eff22738026 /src/libstd/ffi | |
| parent | 0fad2e038a669aad7123f143cbb03ea6492b7e8e (diff) | |
| download | rust-7f687f8602e1d3d8290c154ec67bb8fbd5f493d7.tar.gz rust-7f687f8602e1d3d8290c154ec67bb8fbd5f493d7.zip | |
Add doc example for `CStr::to_bytes_with_nul`.
Diffstat (limited to 'src/libstd/ffi')
| -rw-r--r-- | src/libstd/ffi/c_str.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index ecad407f261..8b18b2f1255 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -826,6 +826,15 @@ impl CStr { /// > length calculation whenever this method is called. /// /// [`to_bytes`]: #method.to_bytes + /// + /// # Examples + /// + /// ``` + /// use std::ffi::CStr; + /// + /// let c_str = CStr::from_bytes_with_nul(b"foo\0").unwrap(); + /// assert_eq!(c_str.to_bytes_with_nul(), b"foo\0"); + /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn to_bytes_with_nul(&self) -> &[u8] { |
