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
)