syn

Function parse2

Source
pub fn parse2<T: Parse>(tokens: TokenStream) -> Result<T>
Expand description

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

This function parses a proc_macro2::TokenStream which is commonly useful when the input comes from a node of the Syn syntax tree, for example the body tokens of a Macro node. When in a procedural macro parsing the proc_macro::TokenStream provided by the compiler, use syn::parse instead.

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.