nom

Trait 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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<'a> InputIter for &'a str

Source§

type Item = char

Source§

type Iter = CharIndices<'a>

Source§

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; 0]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 1]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 2]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 3]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 4]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 5]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 6]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 7]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 8]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 9]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 10]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 11]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 12]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 13]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 14]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 15]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 16]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 17]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 18]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 19]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 20]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 21]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 22]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 23]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 24]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 25]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 26]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 27]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 28]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 29]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 30]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 31]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8; 32]

Source§

type Item = u8

Source§

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

Source§

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> InputIter for &'a [u8]

Source§

type Item = u8

Source§

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

Source§

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§