Struct pest::iterators::Pairs[][src]

pub struct Pairs<'i, R> { /* fields omitted */ }

An iterator over Pairs. It is created by pest::state and Pair::into_inner.

Implementations

impl<'i, R: RuleType> Pairs<'i, R>[src]

pub fn single(pair: Pair<'i, R>) -> Self[src]

Create a new Pairs iterator containing just the single Pair.

impl<'i, R: RuleType> Pairs<'i, R>[src]

pub fn as_str(&self) -> &'i str[src]

Captures a slice from the &str defined by the starting position of the first token Pair and the ending position of the last token Pair of the Pairs. This also captures the input between those two token Pairs.

Examples

enum Rule {
    a,
    b
}

let input = "a b";
let pairs = pest::state(input, |state| {
    // generating Token pairs with Rule::a and Rule::b ...
}).unwrap();

assert_eq!(pairs.as_str(), "a b");

pub fn concat(&self) -> String[src]

Captures inner token Pairs and concatenates resulting &strs. This does not capture the input between token Pairs.

Examples

enum Rule {
    a,
    b
}

let input = "a b";
let pairs = pest::state(input, |state| {
    // generating Token pairs with Rule::a and Rule::b ...
}).unwrap();

assert_eq!(pairs.concat(), "ab");

pub fn flatten(self) -> FlatPairs<'i, R>

Notable traits for FlatPairs<'i, R>

impl<'i, R: RuleType> Iterator for FlatPairs<'i, R> type Item = Pair<'i, R>;
[src]

Flattens the Pairs.

Examples

enum Rule {
    a,
    b
}

let input = "";
let pairs = pest::state(input, |state| {
    // generating nested Token pair with Rule::b inside Rule::a
}).unwrap();
let tokens: Vec<_> = pairs.flatten().tokens().collect();

assert_eq!(tokens.len(), 4);

pub fn tokens(self) -> Tokens<'i, R>

Notable traits for Tokens<'i, R>

impl<'i, R: RuleType> Iterator for Tokens<'i, R> type Item = Token<'i, R>;
[src]

Returns the Tokens for the Pairs.

Examples

enum Rule {
    a
}

let input = "";
let pairs = pest::state(input, |state| {
    // generating Token pair with Rule::a ...
}).unwrap();
let tokens: Vec<_> = pairs.tokens().collect();

assert_eq!(tokens.len(), 2);

pub fn peek(&self) -> Option<Pair<'i, R>>[src]

Peek at the first inner Pair without changing the position of this iterator.

Trait Implementations

impl<'i, R: Clone> Clone for Pairs<'i, R>[src]

impl<'i, R: RuleType> Debug for Pairs<'i, R>[src]

impl<'i, R: RuleType> Display for Pairs<'i, R>[src]

impl<'i, R: RuleType> DoubleEndedIterator for Pairs<'i, R>[src]

impl<'i, R: Eq> Eq for Pairs<'i, R>[src]

impl<'i, R: Hash> Hash for Pairs<'i, R>[src]

impl<'i, R: RuleType> Iterator for Pairs<'i, R>[src]

type Item = Pair<'i, R>

The type of the elements being iterated over.

impl<'i, R: PartialEq> PartialEq<Pairs<'i, R>> for Pairs<'i, R>[src]

Auto Trait Implementations

impl<'i, R> !RefUnwindSafe for Pairs<'i, R>

impl<'i, R> !Send for Pairs<'i, R>

impl<'i, R> !Sync for Pairs<'i, R>

impl<'i, R> Unpin for Pairs<'i, R>

impl<'i, R> UnwindSafe for Pairs<'i, R> where
    R: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.