pub struct Pair<'i>(/* private fields */);
Implementations§
Methods from Deref<Target = Pair<'i, Rule>>§
Sourcepub fn as_rule(&self) -> R
pub fn as_rule(&self) -> R
Returns the Rule
of the Pair
.
§Examples
enum Rule {
a
}
let input = "";
let pair = pest::state(input, |state| {
// generating Token pair with Rule::a ...
}).unwrap().next().unwrap();
assert_eq!(pair.as_rule(), Rule::a);
Sourcepub fn as_str(&self) -> &'i str
pub fn as_str(&self) -> &'i str
Captures a slice from the &str
defined by the token Pair
.
§Examples
enum Rule {
ab
}
let input = "ab";
let pair = pest::state(input, |state| {
// generating Token pair with Rule::ab ...
}).unwrap().next().unwrap();
assert_eq!(pair.as_str(), "ab");
Sourcepub fn get_input(&self) -> &'i str
pub fn get_input(&self) -> &'i str
Returns the input string of the Pair
.
This function returns the input string of the Pair
as a &str
. This is the source string
from which the Pair
was created. The returned &str
can be used to examine the contents of
the Pair
or to perform further processing on the string.
§Examples
enum Rule {
ab
}
// Example: Get input string from a Pair
let input = "ab";
let pair = pest::state(input, |state| {
// generating Token pair with Rule::ab ...
}).unwrap().next().unwrap();
assert_eq!(pair.as_str(), "ab");
assert_eq!(input, pair.get_input());
Sourcepub fn as_span(&self) -> Span<'i>
pub fn as_span(&self) -> Span<'i>
Returns the Span
defined by the Pair
, without consuming it.
§Examples
enum Rule {
ab
}
let input = "ab";
let pair = pest::state(input, |state| {
// generating Token pair with Rule::ab ...
}).unwrap().next().unwrap();
assert_eq!(pair.as_span().as_str(), "ab");
Sourcepub fn as_node_tag(&self) -> Option<&str>
pub fn as_node_tag(&self) -> Option<&str>
Get current node tag
Trait Implementations§
Source§impl SrcReferrer for Pair<'_>
impl SrcReferrer for Pair<'_>
Auto Trait Implementations§
impl<'i> Freeze for Pair<'i>
impl<'i> RefUnwindSafe for Pair<'i>
impl<'i> !Send for Pair<'i>
impl<'i> !Sync for Pair<'i>
impl<'i> Unpin for Pair<'i>
impl<'i> UnwindSafe for Pair<'i>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more