Trait nom::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) -> Option<usize>;
}
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) -> Option<usize>

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

Object Safety§

This trait is not object safe.

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) -> Option<usize>

source§

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

§

type Item = u8

§

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

§

type IterElem = Map<Iter<'a, <&'a [u8] as InputIter>::Item>, fn(_: &u8) -> 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) -> Option<usize>

Implementors§