Trait Parser

Source
pub trait Parser: Sized {
    type Output;

    // Required method
    fn parse(self, tokens: TokenStream) -> Result<Self::Output>;
}
Expand description

A parser that can parse a stream of tokens into a syntax tree node.

Required Associated Types§

Source

type Output

The return type of this parser.

Required Methods§

Source

fn parse(self, tokens: TokenStream) -> Result<Self::Output>

Parses a TokenStream into the relevant syntax tree node.

§Errors

This function returns an error if source doesn’t contain a valid instance of T.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<F: FnOnce(ParseStream<'_>) -> Result<T>, T> Parser for F