pub trait FromPair<'i>: Sized {
const RULE: Rule;
unsafe fn from_pair_unchecked(
pair: Pair<'i, Rule>,
cache: &Cache
) -> Result<Self, SyntaxError>;
fn from_pair(
pair: Pair<'i, Rule>,
cache: &Cache
) -> Result<Self, SyntaxError> { ... }
}
Expand description
A trait for structures that can be parsed from a pest::Pair
.
Associated Constants
Required methods
unsafe fn from_pair_unchecked(
pair: Pair<'i, Rule>,
cache: &Cache
) -> Result<Self, SyntaxError>
unsafe fn from_pair_unchecked(
pair: Pair<'i, Rule>,
cache: &Cache
) -> Result<Self, SyntaxError>
Create a new instance from a Pair
without checking the rule.
Safety
May panic if the pair was not produced by the right rule, i.e.
pair.as_rule() != <Self as FromPair>::RULE
.