doc.rust-lang.org
pub struct FromBytesUntilNulError
An error indicating that no nul byte was present.
struct
core
Stable since 1.69.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn to_str(&self) -> Result<&str, str::Utf8Error>
Yields a &strstr slice if the CStr contains valid UTF-8.
method
core
Stable since 1.4.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn to_bytes_with_nul(&self) -> &[u8]
Converts this C string to a byte slice containing the trailing 0 byte.
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn to_bytes(&self) -> &[u8]
Converts this C string to a byte slice.
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn is_empty(&self) -> bool
Returns true if self.to_bytes() has a length of 0.
method
core
Stable since 1.71.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn from_ptr<'a>(ptr: *const c_char) -> &'a CStr
Wraps a raw C string with a safe C string wrapper.
associated_function
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const unsafe fn from_bytes_with_nul_unchecked(bytes: &[u8]) -> &CStr
Unsafely creates a C string wrapper from a byte slice.
associated_function
core
Stable since 1.10.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn from_bytes_with_nul(bytes: &[u8]) -> Result<&Self, FromBytesWithNulError>
Creates a C string wrapper from a byte slice with exactly one nul terminator.
associated_function
core
Stable since 1.10.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn from_bytes_until_nul(bytes: &[u8]) -> Result<&CStr, FromBytesUntilNulError>
Creates a C string wrapper from a byte slice with any number of nuls.
associated_function
core
Stable since 1.69.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn count_bytes(&self) -> usize
Returns the length of self. Like C's strlen, this does not include the nul terminator.
method
core
Stable since 1.79.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn as_ptr(&self) -> *const c_char
Returns the inner pointer to this C string.
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub struct CStr
A dynamically-sized view of a C string.
struct
core
Stable since 1.64.0
Version 1.100.0-nightly
doc.rust-lang.org
pub mod c_str
CStr and its related types.
module
core
Stable since 1.88.0
Version 1.100.0-nightly
doc.rust-lang.org
pub mod ffi
Platform-specific types, as defined by C.
module
core
Stable since 1.30.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn total_cmp(&self, other: &Self) -> crate::cmp::Ordering
Returns the ordering between self and other.
method
core
Stable since 1.62.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn to_radians(self) -> f64
Converts degrees to radians.
method
core
Stable since 1.0.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn to_ne_bytes(self) -> [u8; 8]
Returns the memory representation of this floating point number as a byte array in native byte order.
method
core
Stable since 1.40.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn to_le_bytes(self) -> [u8; 8]
Returns the memory representation of this floating point number as a byte array in little-endian byte order.
method
core
Stable since 1.40.0
Version 1.100.0-nightly
doc.rust-lang.org
pub unsafe fn to_int_unchecked<Int>(self) -> Int
Rounds toward zero and converts to any primitive integer type, assuming that the value is finite and fits in that type.
method
core
Stable since 1.44.0
Version 1.100.0-nightly
doc.rust-lang.org
pub const fn to_degrees(self) -> f64
Converts radians to degrees.
method
core
Stable since 1.0.0
Version 1.100.0-nightly