Struct noak::mutf8::MStr

source ·
pub struct MStr { /* private fields */ }
Expand description

A Modified UTF-8 string slice, like str.

Implementations§

source§

impl MStr

source

pub fn from_mutf8(v: &[u8]) -> Result<&MStr, DecodeError>

Creates a new string from a modified UTF-8 byte slice.

source

pub fn from_mutf8_mut(v: &mut [u8]) -> Result<&mut MStr, DecodeError>

Creates a new string from a modified UTF-8 byte slice.

source

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.

source

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.

source

pub fn len(&self) -> usize

Returns the length of the string in bytes.

source

pub fn is_empty(&self) -> bool

Returns whether the string contains any characters.

source

pub fn as_bytes(&self) -> &[u8]

Returns the inner byte slice.

source

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.

source

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.

source

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.

source

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).

source

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 AsRef<MStr> for MString

source§

fn as_ref(&self) -> &MStr

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Borrow<MStr> for MString

source§

fn borrow(&self) -> &MStr

Immutably borrows from an owned value. Read more
source§

impl BorrowMut<MStr> for MString

source§

fn borrow_mut(&mut self) -> &mut MStr

Mutably borrows from an owned value. Read more
source§

impl Debug for MStr

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for &'static MStr

source§

fn default() -> &'static MStr

Returns the “default value” for a type. Read more
source§

impl Default for &'static mut MStr

source§

fn default() -> &'static mut MStr

Returns the “default value” for a type. Read more
source§

impl From<&MStr> for MString

source§

fn from(s: &MStr) -> MString

Converts to this type from the input type.
source§

impl Hash for MStr

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
source§

impl Index<Range<usize>> for MStr

§

type Output = MStr

The returned type after indexing.
source§

fn index(&self, index: Range<usize>) -> &MStr

Performs the indexing (container[index]) operation. Read more
source§

impl Index<RangeFrom<usize>> for MStr

§

type Output = MStr

The returned type after indexing.
source§

fn index(&self, index: RangeFrom<usize>) -> &MStr

Performs the indexing (container[index]) operation. Read more
source§

impl Index<RangeFull> for MStr

§

type Output = MStr

The returned type after indexing.
source§

fn index(&self, _: RangeFull) -> &MStr

Performs the indexing (container[index]) operation. Read more
source§

impl Index<RangeInclusive<usize>> for MStr

§

type Output = MStr

The returned type after indexing.
source§

fn index(&self, index: RangeInclusive<usize>) -> &MStr

Performs the indexing (container[index]) operation. Read more
source§

impl Index<RangeTo<usize>> for MStr

§

type Output = MStr

The returned type after indexing.
source§

fn index(&self, index: RangeTo<usize>) -> &MStr

Performs the indexing (container[index]) operation. Read more
source§

impl Index<RangeToInclusive<usize>> for MStr

§

type Output = MStr

The returned type after indexing.
source§

fn index(&self, index: RangeToInclusive<usize>) -> &MStr

Performs the indexing (container[index]) operation. Read more
source§

impl Ord for MStr

source§

fn cmp(&self, other: &MStr) -> Ordering

This method returns an Ordering between self and other. Read more
source§

impl PartialEq<&str> for MStr

source§

fn eq(&self, other: &&str) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<Cow<'_, MStr>> for MStr

source§

fn eq(&self, other: &Cow<'_, MStr>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<MStr> for &str

source§

fn eq(&self, other: &MStr) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<MStr> for Cow<'_, MStr>

source§

fn eq(&self, other: &MStr) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<MStr> for MString

source§

fn eq(&self, other: &MStr) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<MStr> for str

source§

fn eq(&self, other: &MStr) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<MString> for MStr

source§

fn eq(&self, other: &MString) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<str> for MStr

source§

fn eq(&self, other: &str) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq for MStr

source§

fn eq(&self, other: &MStr) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<MStr> for str

source§

fn partial_cmp(&self, other: &MStr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl PartialOrd<str> for MStr

source§

fn partial_cmp(&self, other: &str) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl PartialOrd for MStr

source§

fn partial_cmp(&self, other: &MStr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl ToOwned for MStr

§

type Owned = MString

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> MString

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl Eq for MStr

source§

impl StructuralPartialEq for MStr

Auto Trait Implementations§

§

impl Freeze for MStr

§

impl RefUnwindSafe for MStr

§

impl Send for MStr

§

impl !Sized for MStr

§

impl Sync for MStr

§

impl Unpin for MStr

§

impl UnwindSafe for MStr

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.