Struct pest::iterators::Pairs [−][src]
An iterator over Pair
s. 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 Pair
s.
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 Pair
s and concatenates resulting &str
s. This does not capture
the input between token Pair
s.
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>ⓘ
[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>ⓘ
[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][+]
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,
R: RefUnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src][+]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src][+]
T: ?Sized,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src][+]
I: Iterator,
impl<T> ToOwned for T where
T: Clone,
[src][+]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src][+]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,