pub trait FromPair<'i>: Sized {
const RULE: Rule;
// Required method
unsafe fn from_pair_unchecked(
pair: Pair<'i, Rule>,
cache: &Cache
) -> Result<Self, SyntaxError>;
// Provided method
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
.
Required Associated Constants§
Required Methods§
sourceunsafe 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
.