Skip to content

Commit

Permalink
Add doc example for CString::into_bytes_with_nul.
Browse files Browse the repository at this point in the history
  • Loading branch information
frewsxcv committed Jun 6, 2017
1 parent 3ec1f61 commit 815c12a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libstd/ffi/c_str.rs
Expand Up @@ -353,6 +353,16 @@ impl CString {
/// includes the trailing nul byte.
///
/// [`into_bytes`]: #method.into_bytes
///
/// # Examples
///
/// ```
/// use std::ffi::CString;
///
/// let c_string = CString::new("foo").unwrap();
/// let bytes = c_string.into_bytes_with_nul();
/// assert_eq!(bytes, vec![b'f', b'o', b'o', b'\0']);
/// ```
#[stable(feature = "cstring_into", since = "1.7.0")]
pub fn into_bytes_with_nul(self) -> Vec<u8> {
self.into_inner().into_vec()
Expand Down

0 comments on commit 815c12a

Please sign in to comment.