diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-06-05 23:46:44 -0400 |
|---|---|---|
| committer | Corey Farwell <coreyf@rwell.org> | 2017-06-05 23:46:44 -0400 |
| commit | 3ec1f61accd0386d6923102bd2da30fef4603c47 (patch) | |
| tree | 113a9287da9f12f30363875d909dcb723f2b12ff /src/libstd | |
| parent | 4db8c9f0baef0a5851f6c777d8ce31274bf8c10b (diff) | |
| download | rust-3ec1f61accd0386d6923102bd2da30fef4603c47.tar.gz rust-3ec1f61accd0386d6923102bd2da30fef4603c47.zip | |
Add doc example for `CString::into_bytes`.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ffi/c_str.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/libstd/ffi/c_str.rs b/src/libstd/ffi/c_str.rs index a1ce02b5830..0e8d72c5f3b 100644 --- a/src/libstd/ffi/c_str.rs +++ b/src/libstd/ffi/c_str.rs @@ -331,6 +331,16 @@ impl CString { /// /// The returned buffer does **not** contain the trailing nul separator and /// it is guaranteed to not have any interior nul bytes. + /// + /// # Examples + /// + /// ``` + /// use std::ffi::CString; + /// + /// let c_string = CString::new("foo").unwrap(); + /// let bytes = c_string.into_bytes(); + /// assert_eq!(bytes, vec![b'f', b'o', b'o']); + /// ``` #[stable(feature = "cstring_into", since = "1.7.0")] pub fn into_bytes(self) -> Vec<u8> { let mut vec = self.into_inner().into_vec(); |
