We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
CString::into_bytes
1 parent 4db8c9f commit 3ec1f61Copy full SHA for 3ec1f61
src/libstd/ffi/c_str.rs
@@ -331,6 +331,16 @@ impl CString {
331
///
332
/// The returned buffer does **not** contain the trailing nul separator and
333
/// it is guaranteed to not have any interior nul bytes.
334
+ ///
335
+ /// # Examples
336
337
+ /// ```
338
+ /// use std::ffi::CString;
339
340
+ /// let c_string = CString::new("foo").unwrap();
341
+ /// let bytes = c_string.into_bytes();
342
+ /// assert_eq!(bytes, vec![b'f', b'o', b'o']);
343
344
#[stable(feature = "cstring_into", since = "1.7.0")]
345
pub fn into_bytes(self) -> Vec<u8> {
346
let mut vec = self.into_inner().into_vec();
0 commit comments