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.
CStr::to_bytes
1 parent 29bce6e commit 0fad2e0Copy full SHA for 0fad2e0
src/libstd/ffi/c_str.rs
@@ -800,6 +800,15 @@ impl CStr {
800
/// > **Note**: This method is currently implemented as a 0-cost cast, but
801
/// > it is planned to alter its definition in the future to perform the
802
/// > length calculation whenever this method is called.
803
+ ///
804
+ /// # Examples
805
806
+ /// ```
807
+ /// use std::ffi::CStr;
808
809
+ /// let c_str = CStr::from_bytes_with_nul(b"foo\0").unwrap();
810
+ /// assert_eq!(c_str.to_bytes(), b"foo");
811
812
#[inline]
813
#[stable(feature = "rust1", since = "1.0.0")]
814
pub fn to_bytes(&self) -> &[u8] {
0 commit comments