pub struct Str32(/* private fields */);
Expand description
Implementations§
Source§impl Str32
impl Str32
Sourcepub fn as_mut_str(&mut self) -> &mut str
pub fn as_mut_str(&mut self) -> &mut str
Convert a &mut Str32
to a &mut str
slice.
Sourcepub const fn as_bytes(&self) -> &[u8] ⓘ
pub const fn as_bytes(&self) -> &[u8] ⓘ
Converts the Str32
to a byte slice.
§Examples
let s: &Str32 = "123".try_into().unwrap();
assert_eq!(b"123", s.as_bytes());
Sourcepub unsafe fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
pub unsafe fn as_bytes_mut(&mut self) -> &mut [u8] ⓘ
Converts the Str32
to a byte slice.
§Examples
let mut s = String32::try_from("123").unwrap();
let bytes = unsafe { s.as_bytes_mut() };
assert_eq!(b"123", bytes);
§Safety
See str::as_bytes_mut
.
Sourcepub fn as_mut_ptr(&mut self) -> *mut u8
pub fn as_mut_ptr(&mut self) -> *mut u8
Converts the Str32
to a mutable raw pointer.
The caller must ensure that the string slice is only modified in a way that ensures it is always valid UTF-8.
Sourcepub fn from_mut_str(s: &mut str) -> &mut Self
pub fn from_mut_str(s: &mut str) -> &mut Self
Sourcepub fn len(&self) -> u32
pub fn len(&self) -> u32
Returns the length of the Str32
in bytes.
§Examples
let s: &Str32 = "test".try_into().unwrap();
assert_eq!(4, s.len());
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns whether the Str32
is empty.
§Examples
let s: &Str32 = "".try_into().unwrap();
assert!(s.is_empty());
Sourcepub fn char_indices(&self) -> impl DoubleEndedIterator<Item = (u32, char)> + '_
pub fn char_indices(&self) -> impl DoubleEndedIterator<Item = (u32, char)> + '_
Returns an iterator over the characters of the Str32
, and their byte indices.
Sourcepub fn lines(&self) -> impl DoubleEndedIterator<Item = &Self> + '_
pub fn lines(&self) -> impl DoubleEndedIterator<Item = &Self> + '_
Returns an iterator over the lines of a &Str32
.
Sourcepub fn split_ascii_whitespace(
&self,
) -> impl DoubleEndedIterator<Item = &Self> + '_
pub fn split_ascii_whitespace( &self, ) -> impl DoubleEndedIterator<Item = &Self> + '_
Returns an iterator over the ASCII-whitespace-delimited words of a &Str32
.
Sourcepub fn split_at(&self, mid: u32) -> (&Self, &Self)
pub fn split_at(&self, mid: u32) -> (&Self, &Self)
Splits a &Str32
in two at the given byte index.
§Panics
Panics if mid
is not a UTF-8 code point boundary.
Sourcepub fn split_at_mut(&mut self, mid: u32) -> (&mut Self, &mut Self)
pub fn split_at_mut(&mut self, mid: u32) -> (&mut Self, &mut Self)
Splits a &mut Str32
in two at the given byte index.
§Panics
Panics if mid
is not a UTF-8 code point boundary.
Sourcepub fn split_whitespace(&self) -> impl DoubleEndedIterator<Item = &Self> + '_
pub fn split_whitespace(&self) -> impl DoubleEndedIterator<Item = &Self> + '_
Returns an iterator over the whitespace-delimited words of a &Str32
.
Sourcepub fn eq_ignore_ascii_case(&self, other: &Self) -> bool
pub fn eq_ignore_ascii_case(&self, other: &Self) -> bool
Checks if two string slices are equal, ignoring ASCII case mismatches.
Sourcepub fn escape_debug(&self) -> EscapeDebug<'_>
pub fn escape_debug(&self) -> EscapeDebug<'_>
Return an iterator over the string slice’s chars, each escaped according to char::escape_debug
.
Sourcepub fn escape_default(&self) -> EscapeDefault<'_>
pub fn escape_default(&self) -> EscapeDefault<'_>
Return an iterator over the string slice’s chars, each escaped according to char::escape_default
.
Sourcepub fn escape_unicode(&self) -> EscapeUnicode<'_>
pub fn escape_unicode(&self) -> EscapeUnicode<'_>
Return an iterator over the string slice’s chars, each escaped according to char::escape_unicode
.
Sourcepub fn is_char_boundary(&self, index: u32) -> bool
pub fn is_char_boundary(&self, index: u32) -> bool
Returns whether the given index corresponds to a char
boundary.
Sourcepub fn make_ascii_lowercase(&mut self)
pub fn make_ascii_lowercase(&mut self)
Converts all uppercase ASCII characters to lowercase.
§Examples
let mut s = String32::try_from("ABC").unwrap();
s.make_ascii_lowercase();
assert_eq!("abc", s);
Sourcepub fn make_ascii_uppercase(&mut self)
pub fn make_ascii_uppercase(&mut self)
Converts all lowercase ASCII characters to uppercase.
§Examples
let mut s = String32::try_from("abc").unwrap();
s.make_ascii_uppercase();
assert_eq!("ABC", s);
Sourcepub fn parse<F: FromStr>(&self) -> Result<F, F::Err>
pub fn parse<F: FromStr>(&self) -> Result<F, F::Err>
Parses a &Str32
slice into another type.
§Errors
Will return Err
if this &Str32
slice cannot be parsed into the desired type.
Err
: string32::TryFromStringError
Sourcepub fn to_lowercase(&self) -> String32
pub fn to_lowercase(&self) -> String32
Sourcepub fn to_uppercase(&self) -> String32
pub fn to_uppercase(&self) -> String32
Sourcepub fn to_ascii_lowercase(&self) -> String32
pub fn to_ascii_lowercase(&self) -> String32
Sourcepub fn to_ascii_uppercase(&self) -> String32
pub fn to_ascii_uppercase(&self) -> String32
Sourcepub fn trim(&self) -> &Self
pub fn trim(&self) -> &Self
Returns a substring of this string with leading and trailing whitespace removed.
§Examples
let s: &Str32 = " test\t\n ".try_into().unwrap();
assert_eq!("test", s.trim());
Sourcepub fn trim_start(&self) -> &Self
pub fn trim_start(&self) -> &Self
Returns a substring of this string with leading whitespace removed.
§Examples
let s: &Str32 = " test\t\n ".try_into().unwrap();
assert_eq!("test\t\n ", s.trim_start());
Sourcepub fn trim_end(&self) -> &Self
pub fn trim_end(&self) -> &Self
Returns a substring of this string with trailing whitespace removed.
§Examples
let s: &Str32 = " test\t\n ".try_into().unwrap();
assert_eq!(" test", s.trim_end());
Sourcepub fn into_boxed_str(self: Box<Self>) -> Box<str>
pub fn into_boxed_str(self: Box<Self>) -> Box<str>
Convert a Box<Str32>
into a Box<str>
.
This method has no overhead in the form of copying or allocating.
Sourcepub fn into_boxed_bytes(self: Box<Self>) -> Box<[u8]>
pub fn into_boxed_bytes(self: Box<Self>) -> Box<[u8]>
Convert a Box<Str32>
into Box<[u8]>
.
This method has no overhead in the form of copying or allocating.
Sourcepub fn into_string(self: Box<Self>) -> String
pub fn into_string(self: Box<Self>) -> String
Convert a Box<Str32>
into a String
.
This method has no overhead in the form of copying or allocating.
Sourcepub fn into_string32(self: Box<Self>) -> String32
pub fn into_string32(self: Box<Self>) -> String32
Convert a Box<Str32>
into a String32
.
This method has no overhead in the form of copying or allocating.
Trait Implementations§
Source§impl AddAssign<&Str32> for String32
impl AddAssign<&Str32> for String32
Source§fn add_assign(&mut self, rhs: &Str32)
fn add_assign(&mut self, rhs: &Str32)
+=
operation. Read more