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<'_>
impl AsRef<str> for IndexedSlice<'_>
Source§impl<'a> Clone for IndexedSlice<'a>
impl<'a> Clone for IndexedSlice<'a>
Source§fn clone(&self) -> IndexedSlice<'a>
fn clone(&self) -> IndexedSlice<'a>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a> Debug for IndexedSlice<'a>
impl<'a> Debug for IndexedSlice<'a>
Source§impl Display for IndexedSlice<'_>
impl Display for IndexedSlice<'_>
Source§impl<'a> From<&'a IndexedString> for IndexedSlice<'a>
impl<'a> From<&'a IndexedString> for IndexedSlice<'a>
Source§fn from(s: &'a IndexedString) -> Self
fn from(s: &'a IndexedString) -> Self
Converts to this type from the input type.
Source§impl<'a> From<IndexedSlice<'a>> for IndexedString
impl<'a> From<IndexedSlice<'a>> for IndexedString
Source§fn from(s: IndexedSlice<'a>) -> Self
fn from(s: IndexedSlice<'a>) -> Self
Converts to this type from the input type.
Source§impl IndexedStr for &IndexedSlice<'_>
impl IndexedStr for &IndexedSlice<'_>
Source§fn as_slice(&self) -> IndexedSlice<'_>
fn as_slice(&self) -> IndexedSlice<'_>
Returns a
IndexedSlice
that represents the entire contents of this IndexedStr
.Source§fn len(&self) -> usize
fn len(&self) -> usize
Returns the length of this
IndexedStr
in characters, NOT bytes.Source§fn byte_len(&self) -> usize
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>
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<'_>
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 moreSource§fn chars(&self) -> &[char]
fn chars(&self) -> &[char]
Returns a slice containing all characters of this
IndexedStr
in order.Source§fn to_indexed_string(&self) -> IndexedString
fn to_indexed_string(&self) -> IndexedString
Converts this
IndexedStr
into an owned, dynamically allocated IndexedString
.Source§fn lines(&self) -> IndexedLines<'_> ⓘ
fn lines(&self) -> IndexedLines<'_> ⓘ
Returns an iterator over the lines of this
IndexedStr
.Source§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Returns
true
if this IndexedStr
is empty (of length 0).Source§fn to_lowercase(&self) -> IndexedString
fn to_lowercase(&self) -> IndexedString
Returns a new
IndexedStr
that is the lowercase version of this IndexedStr
.Source§fn to_uppercase(&self) -> IndexedString
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
fn starts_with<S: AsRef<str>>(&self, s: S) -> bool
Returns
true
if this IndexedStr
starts with the given string.Source§impl IndexedStr for IndexedSlice<'_>
impl IndexedStr for IndexedSlice<'_>
Source§fn len(&self) -> usize
fn len(&self) -> usize
Returns the length of this
IndexedStr
in characters, NOT bytes.Source§fn byte_len(&self) -> usize
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>
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<'_>
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 moreSource§fn chars(&self) -> &[char]
fn chars(&self) -> &[char]
Returns a slice containing all characters of this
IndexedStr
in order.Source§fn to_indexed_string(&self) -> IndexedString
fn to_indexed_string(&self) -> IndexedString
Converts this
IndexedStr
into an owned, dynamically allocated IndexedString
.Source§fn as_slice(&self) -> IndexedSlice<'_>
fn as_slice(&self) -> IndexedSlice<'_>
Returns a
IndexedSlice
that represents the entire contents of this IndexedStr
.Source§fn lines(&self) -> IndexedLines<'_> ⓘ
fn lines(&self) -> IndexedLines<'_> ⓘ
Returns an iterator over the lines of this
IndexedStr
.Source§fn is_empty(&self) -> bool
fn is_empty(&self) -> bool
Returns
true
if this IndexedStr
is empty (of length 0).Source§fn to_lowercase(&self) -> IndexedString
fn to_lowercase(&self) -> IndexedString
Returns a new
IndexedStr
that is the lowercase version of this IndexedStr
.Source§fn to_uppercase(&self) -> IndexedString
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
fn starts_with<S: AsRef<str>>(&self, s: S) -> bool
Returns
true
if this IndexedStr
starts with the given string.Source§impl PartialEq<IndexedSlice<'_>> for &IndexedSlice<'_>
impl PartialEq<IndexedSlice<'_>> for &IndexedSlice<'_>
Source§impl PartialEq<IndexedSlice<'_>> for &IndexedString
impl PartialEq<IndexedSlice<'_>> for &IndexedString
Source§impl PartialEq<IndexedSlice<'_>> for &str
impl PartialEq<IndexedSlice<'_>> for &str
Source§impl PartialEq<IndexedSlice<'_>> for String
impl PartialEq<IndexedSlice<'_>> for String
Source§impl PartialEq<IndexedString> for &IndexedSlice<'_>
impl PartialEq<IndexedString> for &IndexedSlice<'_>
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> 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
Mutably borrows from an owned value. Read more