Trait Parser
trait Parser: Sized
Parser that can parse Rust tokens into a particular syntax tree node.
Refer to the module documentation for details about parsing in Syn.
Associated Types
type Output
Required Methods
fn parse2(self: Self, tokens: TokenStream) -> Result<<Self as >::Output>Parse a proc-macro2 token stream into the chosen syntax tree node.
This function enforces that the input is fully parsed. If there are any unparsed tokens at the end of the stream, an error is returned.
Provided Methods
fn parse(self: Self, tokens: proc_macro::TokenStream) -> Result<<Self as >::Output>Parse tokens of source code into the chosen syntax tree node.
This function enforces that the input is fully parsed. If there are any unparsed tokens at the end of the stream, an error is returned.
fn parse_str(self: Self, s: &str) -> Result<<Self as >::Output>Parse a string of Rust code into the chosen syntax tree node.
This function enforces that the input is fully parsed. If there are any unparsed tokens at the end of the string, an error is returned.
Hygiene
Every span in the resulting syntax tree will be set to resolve at the macro call site.
Implementors
impl<F, T> Parser for F