pub struct CString<'a> { /* private fields */ }
Expand description
Type representing a C-compatible string.
Implementations§
Source§impl<'a> CString<'a>
impl<'a> CString<'a>
Sourcepub fn new(s: &'a str) -> Result<CString<'a>, Error>
pub fn new(s: &'a str) -> Result<CString<'a>, Error>
Constructs a new CString from a string slice
The caller MUST ensure that there is a trailing NULL to terminate
the string. To make this easier, the cstr!
macro is provided.
CStrings MUST NOT have any non-ASCII characters, even extended ASCII characters aren’t allowed.
§Examples
use rcstring::CString;
let cs = CString::new("foo\0").unwrap();
Sourcepub unsafe fn from_raw(ptr: *const c_char) -> Result<CString<'a>, Error>
pub unsafe fn from_raw(ptr: *const c_char) -> Result<CString<'a>, Error>
Converts an exising raw pointer to a string and converts it to a
CString
with a length determined by an internal strlen
implementation.
Trait Implementations§
Source§impl<'a> Ord for CString<'a>
impl<'a> Ord for CString<'a>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a> PartialOrd for CString<'a>
impl<'a> PartialOrd for CString<'a>
impl<'a> Eq for CString<'a>
Auto Trait Implementations§
impl<'a> Freeze for CString<'a>
impl<'a> RefUnwindSafe for CString<'a>
impl<'a> !Send for CString<'a>
impl<'a> !Sync for CString<'a>
impl<'a> Unpin for CString<'a>
impl<'a> UnwindSafe for CString<'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