Struct Chars

struct Chars<'a> { ... }

An iterator over Unicode scalar values in a byte string.

When invalid UTF-8 byte sequences are found, they are substituted with the Unicode replacement codepoint (U+FFFD) using the "maximal subpart" strategy.

This iterator is created by the chars method provided by the ByteSlice extension trait for &[u8].

Implementations

impl<'a> Chars<'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 bstr::ByteSlice;

let mut chars = b"abc".chars();

assert_eq!(b"abc", chars.as_bytes());
chars.next();
assert_eq!(b"bc", chars.as_bytes());
chars.next();
chars.next();
assert_eq!(b"", chars.as_bytes());

impl<'a> Clone for Chars<'a>

fn clone(self: &Self) -> Chars<'a>

impl<'a> Debug for Chars<'a>

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

impl<'a> DoubleEndedIterator for Chars<'a>

fn next_back(self: &mut Self) -> Option<char>

impl<'a> Freeze for Chars<'a>

impl<'a> Iterator for Chars<'a>

fn next(self: &mut Self) -> Option<char>

impl<'a> RefUnwindSafe for Chars<'a>

impl<'a> Send for Chars<'a>

impl<'a> Sync for Chars<'a>

impl<'a> Unpin for Chars<'a>

impl<'a> UnsafeUnpin for Chars<'a>

impl<'a> UnwindSafe for Chars<'a>

impl<I> IntoIterator for Chars<'a>

fn into_iter(self: Self) -> I

impl<T> Any for Chars<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Chars<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Chars<'a>

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

impl<T> CloneToUninit for Chars<'a>

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

impl<T> From for Chars<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToOwned for Chars<'a>

fn to_owned(self: &Self) -> T
fn clone_into(self: &Self, target: &mut T)

impl<T, U> Into for Chars<'a>

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for Chars<'a>

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

impl<T, U> TryInto for Chars<'a>

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