Struct IntoChars

#[must_use = "iterators are lazy and do nothing unless consumed"]
pub struct IntoChars { pub(in ::string) bytes: IntoIter<u8> }

An iterator over the chars of a string.

This struct is created by the into_chars method on String. See its documentation for more.

Fields

bytes: IntoIter<u8>

Implementations

impl IntoChars

fn as_str(&self) -> &str

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

Examples

#![feature(string_into_chars)]

let mut chars = String::from("abc").into_chars();

assert_eq!(chars.as_str(), "abc");
chars.next();
assert_eq!(chars.as_str(), "bc");
chars.next();
chars.next();
assert_eq!(chars.as_str(), "");
fn into_string(self) -> String

Consumes the IntoChars, returning the remaining string.

Examples

#![feature(string_into_chars)]

let chars = String::from("abc").into_chars();
assert_eq!(chars.into_string(), "abc");

let mut chars = String::from("def").into_chars();
chars.next();
assert_eq!(chars.into_string(), "ef");
fn iter(&self) -> CharIndices<'_>

Trait Implementations

impl Clone for IntoChars

fn clone(&self) -> IntoChars

impl Debug for IntoChars

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

impl DoubleEndedIterator for IntoChars

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

impl FusedIterator for IntoChars

impl Iterator for IntoChars

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

Auto Trait Implementations

impl Freeze for IntoChars

impl RefUnwindSafe for IntoChars

impl Send for IntoChars

impl Sync for IntoChars

impl Unpin for IntoChars

impl UnsafeUnpin for IntoChars

impl UnwindSafe for IntoChars

Blanket Implementations

impl<I> IntoIterator for IntoChars where I: Iterator,

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

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

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for IntoChars where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for IntoChars where T: ?Sized,

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

impl<T> CloneToUninit for IntoChars where T: Clone,

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

impl<T> From<T> for IntoChars

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for IntoChars where T: ?Sized,

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

impl<T> SizedTypeProperties for IntoChars

impl<T> ToOwned for IntoChars where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T, U> Into<U> for IntoChars 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 IntoChars where U: Into<T>,

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

impl<T, U> TryInto<U> for IntoChars where U: TryFrom<T>,

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