pub trait FromPest<'pest>: Sized {
type Rule: RuleType;
type FatalError;
fn from_pest(
pest: &mut Pairs<'pest, Self::Rule>
) -> Result<Self, ConversionError<Self::FatalError>>;
}
Expand description
Potentially borrowing conversion from a pest parse tree.
Required Associated Types§
sourcetype FatalError
type FatalError
A fatal error during conversion.
Required Methods§
sourcefn from_pest(
pest: &mut Pairs<'pest, Self::Rule>
) -> Result<Self, ConversionError<Self::FatalError>>
fn from_pest(
pest: &mut Pairs<'pest, Self::Rule>
) -> Result<Self, ConversionError<Self::FatalError>>
Convert from a Pest parse tree.
Return type semantics
Err(ConversionError::NoMatch)
=> node not at head of the cursor, cursor unchangedErr(ConversionError::Malformed)
=> fatal error; node at head of the cursor but malformedOk
=> success; the cursor has been updated past this node
Implementations on Foreign Types§
source§impl<'pest, Rule: RuleType, T: FromPest<'pest, Rule = Rule>> FromPest<'pest> for PhantomData<T>
impl<'pest, Rule: RuleType, T: FromPest<'pest, Rule = Rule>> FromPest<'pest> for PhantomData<T>
Convert a production without storing it.
type Rule = Rule
type FatalError = <T as FromPest<'pest>>::FatalError
fn from_pest(
pest: &mut Pairs<'pest, Rule>
) -> Result<Self, ConversionError<T::FatalError>>
source§impl<'pest, Rule: RuleType, T: FromPest<'pest, Rule = Rule>> FromPest<'pest> for Box<T>
impl<'pest, Rule: RuleType, T: FromPest<'pest, Rule = Rule>> FromPest<'pest> for Box<T>
For recursive grammars.
type Rule = Rule
type FatalError = <T as FromPest<'pest>>::FatalError
fn from_pest(
pest: &mut Pairs<'pest, Rule>
) -> Result<Self, ConversionError<T::FatalError>>
source§impl<'pest, Rule: RuleType, T: FromPest<'pest, Rule = Rule>> FromPest<'pest> for Option<T>
impl<'pest, Rule: RuleType, T: FromPest<'pest, Rule = Rule>> FromPest<'pest> for Option<T>
Convert an optional production.
type Rule = Rule
type FatalError = <T as FromPest<'pest>>::FatalError
fn from_pest(
pest: &mut Pairs<'pest, Rule>
) -> Result<Self, ConversionError<T::FatalError>>
source§impl<'pest, Rule: RuleType, T: FromPest<'pest, Rule = Rule>> FromPest<'pest> for Vec<T>
impl<'pest, Rule: RuleType, T: FromPest<'pest, Rule = Rule>> FromPest<'pest> for Vec<T>
Convert many productions. (If <T as FromPest>
is non-advancing, this will be non-terminating.)
type Rule = Rule
type FatalError = <T as FromPest<'pest>>::FatalError
fn from_pest(
pest: &mut Pairs<'pest, Rule>
) -> Result<Self, ConversionError<T::FatalError>>
source§impl<'pest, Rule: RuleType> FromPest<'pest> for Pair<'pest, Rule>
impl<'pest, Rule: RuleType> FromPest<'pest> for Pair<'pest, Rule>
Consume a production without doing any processing.