pub struct CStr<'a> { /* private fields */ }
Expand description
Struct representing a C string.
Implementations§
source§impl<'a> CStr<'a>
impl<'a> CStr<'a>
sourcepub fn from_bytes_with_nul(bytes: &'static [u8]) -> Result<Self, CStrError>
pub fn from_bytes_with_nul(bytes: &'static [u8]) -> Result<Self, CStrError>
Creates a new CStr
instance from a static byte slice that is null-terminated.
§Arguments
bytes
- A static byte slice that must be null-terminated.
§Returns
A new CStr
instance representing the input byte slice.
§Errors
This method will return a CStrError
if the input bytes
slice does not have a null terminator.
sourcepub fn len(self) -> usize
pub fn len(self) -> usize
Calculates the length of the C-style string represented by the CStr
instance.
§Returns
The length of the C-style string, not including the null terminator.
Trait Implementations§
impl<'a> Copy for CStr<'a>
impl Send for CStr<'_>
impl Sync for CStr<'_>
Auto Trait Implementations§
impl<'a> Freeze for CStr<'a>
impl<'a> RefUnwindSafe for CStr<'a>
impl<'a> Unpin for CStr<'a>
impl<'a> UnwindSafe for CStr<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)