pub struct MString { /* private fields */ }
Expand description
A Modified UTF-8 string, but owned, like String
.
Implementations§
source§impl MString
impl MString
sourcepub fn with_capacity(cap: usize) -> MString
pub fn with_capacity(cap: usize) -> MString
Creates an empty string with capacity.
sourcepub fn from_mutf8(buf: Vec<u8>) -> Result<MString, DecodeError>
pub fn from_mutf8(buf: Vec<u8>) -> Result<MString, DecodeError>
Creates a new string from a modified UTF-8 byte vector.
Methods from Deref<Target = MStr>§
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<'a> Extend<&'a str> for MString
impl<'a> Extend<&'a str> for MString
source§fn extend<I: IntoIterator<Item = &'a str>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = &'a str>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl Extend<char> for MString
impl Extend<char> for MString
source§fn extend<I: IntoIterator<Item = char>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = char>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl FromIterator<char> for MString
impl FromIterator<char> for MString
source§impl Ord for MString
impl Ord for MString
source§impl PartialEq<MStr> for MString
impl PartialEq<MStr> for MString
source§impl PartialEq<MString> for MStr
impl PartialEq<MString> for MStr
source§impl PartialEq for MString
impl PartialEq for MString
source§impl PartialOrd for MString
impl PartialOrd for MString
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 moreimpl Eq for MString
impl StructuralPartialEq for MString
Auto Trait Implementations§
impl Freeze for MString
impl RefUnwindSafe for MString
impl Send for MString
impl Sync for MString
impl Unpin for MString
impl UnwindSafe for MString
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
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.