[−][src]Macro syn::many0
Parse zero or more values using the given parser.
- Syntax:
many0!(THING)
- Output:
Vec<THING>
You may also be looking for:
call!(Punctuated::parse_separated)
- zero or more values with separatorcall!(Punctuated::parse_separated_nonempty)
- one or more valuescall!(Punctuated::parse_terminated)
- zero or more, allows trailing separatorcall!(Punctuated::parse_terminated_nonempty)
- one or more
#[macro_use] extern crate syn; use syn::{Ident, Item}; use syn::token::Brace; use syn::synom::Synom; /// Parses a module containing zero or more Rust items. /// /// Example: `mod m { type Result<T> = ::std::result::Result<T, MyError>; }` struct SimpleMod { mod_token: Token![mod], name: Ident, brace_token: Brace, items: Vec<Item>, } impl Synom for SimpleMod { named!(parse -> Self, do_parse!( mod_token: keyword!(mod) >> name: syn!(Ident) >> body: braces!(many0!(syn!(Item))) >> (SimpleMod { mod_token, name, brace_token: body.0, items: body.1, }) )); }
This macro is available if Syn is built with the "parsing"
feature.