pub trait Parser: Sized {
type Output;
// Required method
fn parse2(self, tokens: TokenStream) -> Result<Self::Output, ParseError>;
// Provided methods
fn parse(self, tokens: TokenStream) -> Result<Self::Output, ParseError> { ... }
fn parse_str(self, s: &str) -> Result<Self::Output, ParseError> { ... }
}Expand description
Parser that can parse Rust tokens into a particular syntax tree node.
Refer to the module documentation for details about parsing in Syn.
This trait is available if Syn is built with the "parsing" feature.
Required Associated Types§
Required Methods§
Sourcefn parse2(self, tokens: TokenStream) -> Result<Self::Output, ParseError>
fn parse2(self, tokens: TokenStream) -> Result<Self::Output, ParseError>
Parse a proc-macro2 token stream into the chosen syntax tree node.
Provided Methods§
Sourcefn parse(self, tokens: TokenStream) -> Result<Self::Output, ParseError>
fn parse(self, tokens: TokenStream) -> Result<Self::Output, ParseError>
Parse tokens of source code into the chosen syntax tree node.
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.