Struct CharIndices
struct CharIndices<'a> { ... }
An iterator over Unicode scalar values in a byte string and their byte index positions.
When invalid UTF-8 byte sequences are found, they are substituted with the
Unicode replacement codepoint (U+FFFD) using the
"maximal subpart" strategy.
Note that this is slightly different from the CharIndices iterator
provided by the standard library. Aside from working on possibly invalid
UTF-8, this iterator provides both the corresponding starting and ending
byte indices of each codepoint yielded. The ending position is necessary to
slice the original byte string when invalid UTF-8 bytes are converted into
a Unicode replacement codepoint, since a single replacement codepoint can
substitute anywhere from 1 to 3 invalid bytes (inclusive).
This iterator is created by the
char_indices method provided
by the ByteSlice extension trait for &[u8].
Implementations
impl<'a> CharIndices<'a>
fn as_bytes(self: &Self) -> &'a [u8]View the underlying data as a subslice of the original data.
The slice returned has the same lifetime as the original slice, and so the iterator can continue to be used while this exists.
Examples
use ByteSlice; let mut it = b"abc".char_indices; assert_eq!; it.next; assert_eq!; it.next; it.next; assert_eq!;
impl<'a> Clone for CharIndices<'a>
fn clone(self: &Self) -> CharIndices<'a>
impl<'a> Debug for CharIndices<'a>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<'a> DoubleEndedIterator for CharIndices<'a>
fn next_back(self: &mut Self) -> Option<(usize, usize, char)>
impl<'a> Freeze for CharIndices<'a>
impl<'a> FusedIterator for CharIndices<'a>
impl<'a> Iterator for CharIndices<'a>
fn next(self: &mut Self) -> Option<(usize, usize, char)>
impl<'a> RefUnwindSafe for CharIndices<'a>
impl<'a> Send for CharIndices<'a>
impl<'a> Sync for CharIndices<'a>
impl<'a> Unpin for CharIndices<'a>
impl<'a> UnsafeUnpin for CharIndices<'a>
impl<'a> UnwindSafe for CharIndices<'a>
impl<I> IntoIterator for CharIndices<'a>
fn into_iter(self: Self) -> I
impl<T> Any for CharIndices<'a>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for CharIndices<'a>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for CharIndices<'a>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for CharIndices<'a>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for CharIndices<'a>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for CharIndices<'a>
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for CharIndices<'a>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for CharIndices<'a>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for CharIndices<'a>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>