Trait nom8::input::InputIter

source ·
pub trait InputIter {
    type Item;
    type Iter: Iterator<Item = (usize, Self::Item)>;
    type IterElem: Iterator<Item = Self::Item>;

    // Required methods
    fn iter_indices(&self) -> Self::Iter;
    fn iter_elements(&self) -> Self::IterElem;
    fn position<P>(&self, predicate: P) -> Option<usize>
       where P: Fn(Self::Item) -> bool;
    fn slice_index(&self, count: usize) -> Result<usize, Needed>;
}
Expand description

Abstracts common iteration operations on the input type

Required Associated Types§

source

type Item

The current input type is a sequence of that Item type.

Example: u8 for &[u8] or char for &str

source

type Iter: Iterator<Item = (usize, Self::Item)>

An iterator over the input type, producing the item and its position for use with Slice. If we’re iterating over &str, the position corresponds to the byte index of the character

source

type IterElem: Iterator<Item = Self::Item>

An iterator over the input type, producing the item

Required Methods§

source

fn iter_indices(&self) -> Self::Iter

Returns an iterator over the elements and their byte offsets

source

fn iter_elements(&self) -> Self::IterElem

Returns an iterator over the elements

source

fn position<P>(&self, predicate: P) -> Option<usize>where P: Fn(Self::Item) -> bool,

Finds the byte position of the element

source

fn slice_index(&self, count: usize) -> Result<usize, Needed>

Get the byte offset from the element’s position in the stream

Implementations on Foreign Types§

source§

impl<'a> InputIter for &'a str

§

type Item = char

§

type Iter = CharIndices<'a>

§

type IterElem = Chars<'a>

source§

fn iter_indices(&self) -> Self::Iter

source§

fn iter_elements(&self) -> Self::IterElem

source§

fn position<P>(&self, predicate: P) -> Option<usize>where P: Fn(Self::Item) -> bool,

source§

fn slice_index(&self, count: usize) -> Result<usize, Needed>

source§

impl<'a> InputIter for &'a [u8]

§

type Item = u8

§

type Iter = Enumerate<<&'a [u8] as InputIter>::IterElem>

§

type IterElem = Copied<Iter<'a, u8>>

source§

fn iter_indices(&self) -> Self::Iter

source§

fn iter_elements(&self) -> Self::IterElem

source§

fn position<P>(&self, predicate: P) -> Option<usize>where P: Fn(Self::Item) -> bool,

source§

fn slice_index(&self, count: usize) -> Result<usize, Needed>

source§

impl<'a, const LEN: usize> InputIter for &'a [u8; LEN]

§

type Item = u8

§

type Iter = Enumerate<<&'a [u8; LEN] as InputIter>::IterElem>

§

type IterElem = Copied<Iter<'a, u8>>

source§

fn iter_indices(&self) -> Self::Iter

source§

fn iter_elements(&self) -> Self::IterElem

source§

fn position<P>(&self, predicate: P) -> Option<usize>where P: Fn(Self::Item) -> bool,

source§

fn slice_index(&self, count: usize) -> Result<usize, Needed>

Implementors§

source§

impl<I> InputIter for Located<I>where I: InputIter,

§

type Item = <I as InputIter>::Item

§

type Iter = <I as InputIter>::Iter

§

type IterElem = <I as InputIter>::IterElem

source§

impl<I> InputIter for Streaming<I>where I: InputIter,

§

type Item = <I as InputIter>::Item

§

type Iter = <I as InputIter>::Iter

§

type IterElem = <I as InputIter>::IterElem

source§

impl<I, S> InputIter for Stateful<I, S>where I: InputIter,

§

type Item = <I as InputIter>::Item

§

type Iter = <I as InputIter>::Iter

§

type IterElem = <I as InputIter>::IterElem