Lines Matching defs:CString
66 /// # use kernel::{prelude::fmt, b_str, str::{BStr, CString}};
68 /// let s = CString::try_from_fmt(fmt!("{ascii}"))?;
72 /// let s = CString::try_from_fmt(fmt!("{non_ascii}"))?;
97 /// # use kernel::{prelude::fmt, b_str, str::{BStr, CString}};
100 /// let s = CString::try_from_fmt(fmt!("{ascii:?}"))?;
104 /// let s = CString::try_from_fmt(fmt!("{non_ascii:?}"))?;
230 /// Convert this [`CStr`] into a [`CString`] by allocating memory and
232 fn to_cstring(&self) -> Result<CString, AllocError>;
256 /// Returns a copy of this [`CString`] where each character is mapped to its
265 fn to_ascii_lowercase(&self) -> Result<CString, AllocError>;
267 /// Returns a copy of this [`CString`] where each character is mapped to its
276 fn to_ascii_uppercase(&self) -> Result<CString, AllocError>;
285 /// # use kernel::str::CString;
287 /// let s = CString::try_from_fmt(fmt!("{penguin}"))?;
291 /// let s = CString::try_from_fmt(fmt!("{ascii}"))?;
344 fn to_cstring(&self) -> Result<CString, AllocError> {
345 CString::try_from(self)
358 fn to_ascii_lowercase(&self) -> Result<CString, AllocError> {
366 fn to_ascii_uppercase(&self) -> Result<CString, AllocError> {
431 CString::try_from_fmt(fmt!($($f)*))?.to_str()?
812 /// use kernel::{str::CString, prelude::fmt};
814 /// let s = CString::try_from_fmt(fmt!("{}{}{}", "abc", 10, 20))?;
818 /// let s = CString::try_from_fmt(fmt!("{tmp}{}", 123))?;
822 /// let s = CString::try_from_fmt(fmt!("a\0b{}", 123));
826 pub struct CString {
830 impl CString {
831 /// Creates an instance of [`CString`] from the given formatted arguments.
868 impl Deref for CString {
878 impl DerefMut for CString {
880 // SAFETY: A `CString` is always NUL-terminated and contains no other
886 impl<'a> TryFrom<&'a CStr> for CString {
889 fn try_from(cstr: &'a CStr) -> Result<CString, AllocError> {
894 // INVARIANT: The `CStr` and `CString` types have the same invariants for
896 Ok(CString { buf })
900 impl fmt::Debug for CString {