Struct IndexedSlice

Source
pub struct IndexedSlice<'a> { /* private fields */ }
Expand description

A &str replacement that allows for safe indexing and slicing of multi-byte characters.

This is the borrowed counterpart to IndexedString.

Trait Implementations§

Source§

impl AsRef<str> for IndexedSlice<'_>

Source§

fn as_ref(&self) -> &str

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

impl<'a> Clone for IndexedSlice<'a>

Source§

fn clone(&self) -> IndexedSlice<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for IndexedSlice<'a>

Source§

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

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

impl Display for IndexedSlice<'_>

Source§

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

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

impl<'a> From<&'a IndexedString> for IndexedSlice<'a>

Source§

fn from(s: &'a IndexedString) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<IndexedSlice<'a>> for IndexedString

Source§

fn from(s: IndexedSlice<'a>) -> Self

Converts to this type from the input type.
Source§

impl IndexedStr for &IndexedSlice<'_>

Source§

fn as_str(&self) -> &str

Returns a &str representation of this IndexedStr. Read more
Source§

fn as_slice(&self) -> IndexedSlice<'_>

Returns a IndexedSlice that represents the entire contents of this IndexedStr.
Source§

fn len(&self) -> usize

Returns the length of this IndexedStr in characters, NOT bytes.
Source§

fn byte_len(&self) -> usize

Returns the byte length of this IndexedStr. This will be longer than the len if the string contains multi-byte characters.
Source§

fn char_at(&self, index: usize) -> Option<char>

Returns the character at the given index, if it exists.
Source§

fn slice<R: RangeBounds<usize>>(&self, range: R) -> IndexedSlice<'_>

Returns a sub-slice of this IndexedStr based on the given range in terms of the characters in the string, not bytes. Read more
Source§

fn chars(&self) -> &[char]

Returns a slice containing all characters of this IndexedStr in order.
Source§

fn to_indexed_string(&self) -> IndexedString

Converts this IndexedStr into an owned, dynamically allocated IndexedString.
Source§

fn lines(&self) -> IndexedLines<'_>

Returns an iterator over the lines of this IndexedStr.
Source§

fn is_empty(&self) -> bool

Returns true if this IndexedStr is empty (of length 0).
Source§

fn to_lowercase(&self) -> IndexedString

Returns a new IndexedStr that is the lowercase version of this IndexedStr.
Source§

fn to_uppercase(&self) -> IndexedString

Returns a new IndexedStr that is the uppercase version of this IndexedStr.
Source§

fn starts_with<S: AsRef<str>>(&self, s: S) -> bool

Returns true if this IndexedStr starts with the given string.
Source§

fn ends_with<S: AsRef<str>>(&self, s: S) -> bool

Returns true if this IndexedStr ends with the given string.
Source§

fn parse<F>(&self) -> Result<F, <F as FromStr>::Err>
where F: FromStr,

Parses this IndexedStr into a value of type F using the FromStr trait.
Source§

impl IndexedStr for IndexedSlice<'_>

Source§

fn as_str(&self) -> &str

Returns a &str representation of this IndexedStr. Read more
Source§

fn len(&self) -> usize

Returns the length of this IndexedStr in characters, NOT bytes.
Source§

fn byte_len(&self) -> usize

Returns the byte length of this IndexedStr. This will be longer than the len if the string contains multi-byte characters.
Source§

fn char_at(&self, index: usize) -> Option<char>

Returns the character at the given index, if it exists.
Source§

fn slice<R: RangeBounds<usize>>(&self, range: R) -> IndexedSlice<'_>

Returns a sub-slice of this IndexedStr based on the given range in terms of the characters in the string, not bytes. Read more
Source§

fn chars(&self) -> &[char]

Returns a slice containing all characters of this IndexedStr in order.
Source§

fn to_indexed_string(&self) -> IndexedString

Converts this IndexedStr into an owned, dynamically allocated IndexedString.
Source§

fn as_slice(&self) -> IndexedSlice<'_>

Returns a IndexedSlice that represents the entire contents of this IndexedStr.
Source§

fn lines(&self) -> IndexedLines<'_>

Returns an iterator over the lines of this IndexedStr.
Source§

fn is_empty(&self) -> bool

Returns true if this IndexedStr is empty (of length 0).
Source§

fn to_lowercase(&self) -> IndexedString

Returns a new IndexedStr that is the lowercase version of this IndexedStr.
Source§

fn to_uppercase(&self) -> IndexedString

Returns a new IndexedStr that is the uppercase version of this IndexedStr.
Source§

fn starts_with<S: AsRef<str>>(&self, s: S) -> bool

Returns true if this IndexedStr starts with the given string.
Source§

fn ends_with<S: AsRef<str>>(&self, s: S) -> bool

Returns true if this IndexedStr ends with the given string.
Source§

fn parse<F>(&self) -> Result<F, <F as FromStr>::Err>
where F: FromStr,

Parses this IndexedStr into a value of type F using the FromStr trait.
Source§

impl PartialEq<IndexedSlice<'_>> for &IndexedSlice<'_>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<IndexedSlice<'_>> for &IndexedString

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<IndexedSlice<'_>> for &str

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<IndexedSlice<'_>> for String

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<IndexedString> for &IndexedSlice<'_>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<S: AsRef<str>> PartialEq<S> for IndexedSlice<'_>

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Eq for IndexedSlice<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for IndexedSlice<'a>

§

impl<'a> RefUnwindSafe for IndexedSlice<'a>

§

impl<'a> Send for IndexedSlice<'a>

§

impl<'a> Sync for IndexedSlice<'a>

§

impl<'a> Unpin for IndexedSlice<'a>

§

impl<'a> UnwindSafe for IndexedSlice<'a>

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

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

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.