[][src]Trait syn::parse::Parser

pub trait Parser: Sized {
    type Output;
    pub fn parse2(self, tokens: TokenStream) -> Result<Self::Output>;

    pub fn parse(self, tokens: TokenStream) -> Result<Self::Output> { ... }
pub fn parse_str(self, s: &str) -> Result<Self::Output> { ... } }

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 only if Syn is built with the "parsing" feature.

Associated Types

type Output[src]

Loading content...

Required methods

pub fn parse2(self, tokens: TokenStream) -> Result<Self::Output>[src]

Parse a proc-macro2 token stream into the chosen syntax tree node.

This function will check that the input is fully parsed. If there are any unparsed tokens at the end of the stream, an error is returned.

Loading content...

Provided methods

pub fn parse(self, tokens: TokenStream) -> Result<Self::Output>[src]

Parse tokens of source code into the chosen syntax tree node.

This function will check that the input is fully parsed. If there are any unparsed tokens at the end of the stream, an error is returned.

This method is available only if Syn is built with both the "parsing" and "proc-macro" features.

pub fn parse_str(self, s: &str) -> Result<Self::Output>[src]

Parse a string of Rust code into the chosen syntax tree node.

This function will check 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.

Loading content...

Implementors

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

type Output = T

Loading content...