Struct safe_string::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<'a> AsRef<str> for IndexedSlice<'a>
impl<'a> AsRef<str> for IndexedSlice<'a>
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<'a> Display for IndexedSlice<'a>
impl<'a> Display for IndexedSlice<'a>
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 Index<usize> for IndexedSlice<'_>
impl Index<usize> for IndexedSlice<'_>
source§impl<'a> IndexedStr for IndexedSlice<'a>
impl<'a> IndexedStr for IndexedSlice<'a>
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 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
.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