Struct pest::iterators::Pair
[−]
[src]
pub struct Pair<'i, R> { /* fields omitted */ }
A struct
containing a matching pair of Token
s and everything between them.
A matching Token
pair is formed by a Token::Start
and a subsequent Token::End
with the
same Rule
, with the condition that all Token
s between them can form such pairs as well.
This is similar to the brace matching problem in
editors.
Methods
impl<'i, R: RuleType> Pair<'i, R>
[src]
fn as_rule(&self) -> R
[src]
Returns the Rule
of the Pair
.
Examples
enum Rule { a } let input = ""; let pair = pest::state(input, |state, pos| { // generating Token pair with Rule::a ... }).unwrap().next().unwrap(); assert_eq!(pair.as_rule(), Rule::a);
fn as_str(&self) -> &'i str
[src]
Captures a slice from the &str
defined by the token Pair
.
Examples
enum Rule { ab } let input = "ab"; let pair = pest::state(input, |state, pos| { // generating Token pair with Rule::ab ... }).unwrap().next().unwrap(); assert_eq!(pair.as_str(), "ab");
fn into_span(self) -> Span<'i>
[src]
Returns the Span
defined by the Pair
, consuming it.
Examples
enum Rule { ab } let input = "ab"; let pair = pest::state(input, |state, pos| { // generating Token pair with Rule::ab ... }).unwrap().next().unwrap(); assert_eq!(pair.into_span().as_str(), "ab");
fn into_inner(self) -> Pairs<'i, R>
[src]
Returns the inner Pairs
between the Pair
, consuming it.
Examples
enum Rule { a } let input = ""; let pair = pest::state(input, |state, pos| { // generating Token pair with Rule::a ... }).unwrap().next().unwrap(); assert!(pair.into_inner().next().is_none());
fn tokens(self) -> Tokens<'i, R>
[src]
Converts the Pair
into a TokenIterator
.
Examples
enum Rule { a } let input = ""; let pair = pest::state(input, |state, pos| { // generating Token pair with Rule::a ... }).unwrap().next().unwrap(); let tokens: Vec<_> = pair.tokens().collect(); assert_eq!(tokens.len(), 2);
Trait Implementations
impl<'i, R: Clone> Clone for Pair<'i, R>
[src]
fn clone(&self) -> Pair<'i, R>
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl<'i, R: RuleType> Debug for Pair<'i, R>
[src]
impl<'i, R: RuleType> Display for Pair<'i, R>
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl<'i, R: PartialEq> PartialEq for Pair<'i, R>
[src]
fn eq(&self, other: &Pair<'i, R>) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.