Struct Chars

#[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct Chars<'a> { pub(in ::str) iter: Iter<'a, u8> }

An iterator over the chars of a string slice.

This struct is created by the chars method on str. See its documentation for more.

Fields

iter: Iter<'a, u8>

Implementations

impl<'a> Chars<'a>

fn as_str(&self) -> &'a str

Views the underlying data as a subslice of the original data.

This has the same lifetime as the original slice, and so the iterator can continue to be used while this exists.

Examples

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

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

Trait Implementations

impl Debug for Chars<'_>

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

impl FusedIterator for Chars<'_>

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

fn clone(&self) -> Self

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

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

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

type Item = char;
fn next(&mut self) -> Option<char>
fn count(self) -> usize
fn advance_by(&mut self, remainder: usize) -> Result<(), NonZero<usize>>
fn size_hint(&self) -> (usize, Option<usize>)
fn last(self) -> Option<char>

Auto Trait Implementations

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

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>

Blanket Implementations

impl<I> IntoIterator for Chars<'a> where I: Iterator,

type Item = <I as Iterator>::Item;
type IntoIter = I;
fn into_iter(self) -> I

impl<T> Any for Chars<'a> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Chars<'a> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Chars<'a> where T: ?Sized,

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

impl<T> CloneToUninit for Chars<'a> where T: Clone,

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

impl<T> From<T> for Chars<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for Chars<'a> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for Chars<'a>

impl<T, U> Into<U> for Chars<'a> where U: From<T>,

fn into(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<U> for Chars<'a> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Chars<'a> where U: TryFrom<T>,

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