pub struct MStr { /* private fields */ }
Expand description
A Modified UTF-8 string slice, like str.
Implementations§
source§impl MStr
impl MStr
sourcepub fn from_mutf8(v: &[u8]) -> Result<&MStr, DecodeError>
pub fn from_mutf8(v: &[u8]) -> Result<&MStr, DecodeError>
Creates a new string from a modified UTF-8 byte slice.
sourcepub fn from_mutf8_mut(v: &mut [u8]) -> Result<&mut MStr, DecodeError>
pub fn from_mutf8_mut(v: &mut [u8]) -> Result<&mut MStr, DecodeError>
Creates a new string from a modified UTF-8 byte slice.
sourcepub const unsafe fn from_mutf8_unchecked(v: &[u8]) -> &MStr
pub const unsafe fn from_mutf8_unchecked(v: &[u8]) -> &MStr
Creates a string from a modified UTF-8 byte slice without checking its contents.
§Safety
This slice may not contain bytes that do not make up a modified UTF-8 string.
sourcepub unsafe fn from_mutf8_unchecked_mut(v: &mut [u8]) -> &mut MStr
pub unsafe fn from_mutf8_unchecked_mut(v: &mut [u8]) -> &mut MStr
Creates a string from a modified UTF-8 byte slice without checking its contents.
§Safety
This slice may not contain bytes that do not make up a modified UTF-8 string.
sourcepub fn to_str(&self) -> Option<&str>
pub fn to_str(&self) -> Option<&str>
Checks whether the modified UTF-8 string is valid UTF-8 and returns a &str
if it is.
sourcepub fn is_char_boundary(&self, index: usize) -> bool
pub fn is_char_boundary(&self, index: usize) -> bool
Returns whether the index
-th byte is the first byte of a modified UTF-8 code point sequence or the end of the string.
sourcepub fn chars(&self) -> Chars<'_> ⓘ
pub fn chars(&self) -> Chars<'_> ⓘ
Returns an iterator over the chars in this string.
For valid unicode characters, Ok
is yielded.
If a character is invalid, then its code will be returned in the Err
case.
If you don’t care about invalid characters, use chars_lossy
.
sourcepub fn chars_lossy(&self) -> CharsLossy<'_> ⓘ
pub fn chars_lossy(&self) -> CharsLossy<'_> ⓘ
Returns an iterator over the chars in this string.
Invalid characters are replaced with U+FFFD (char::REPLACEMENT_CHARACTER
).
sourcepub fn display(&self) -> Display<'_>
pub fn display(&self) -> Display<'_>
Provides a value of a type that implements Display
.
Invalid characters are displayed as U+FFFD (char::REPLACEMENT_CHARACTER
).
Trait Implementations§
source§impl BorrowMut<MStr> for MString
impl BorrowMut<MStr> for MString
source§fn borrow_mut(&mut self) -> &mut MStr
fn borrow_mut(&mut self) -> &mut MStr
source§impl PartialEq<&str> for MStr
impl PartialEq<&str> for MStr
source§impl PartialEq<Cow<'_, MStr>> for MStr
impl PartialEq<Cow<'_, MStr>> for MStr
source§impl PartialEq<MStr> for &str
impl PartialEq<MStr> for &str
source§impl PartialEq<MStr> for Cow<'_, MStr>
impl PartialEq<MStr> for Cow<'_, MStr>
source§impl PartialEq<MStr> for MString
impl PartialEq<MStr> for MString
source§impl PartialEq<MStr> for str
impl PartialEq<MStr> for str
source§impl PartialEq<MString> for MStr
impl PartialEq<MString> for MStr
source§impl PartialEq for MStr
impl PartialEq for MStr
source§impl PartialOrd<MStr> for str
impl PartialOrd<MStr> for str
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd<str> for MStr
impl PartialOrd<str> for MStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl PartialOrd for MStr
impl PartialOrd for MStr
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more