Function parse_struct

Source
pub fn parse_struct<'s, F, S>(inputs: &[S], func: F) -> Result<()>
where S: Borrow<ParseBuffer<'s>>, F: FnMut(ParseStream<'_>, &str, Span) -> Result<()>,
Expand description

Parses an inline struct with named fields from a stream.

Each stream in inputs will be parsed in order, first parsing a path by calling syn::Path::parse_mod_style. Then, func will be called for every field with three arguments: the current stream, the name of the field as a string, and the span of the field name. Commas will be parsed between each field. A trailing comma will always be consumed. Callers will typically check the field name for a match, and then call parse_named_meta_item or parse_named_meta_item_with.

Callers will usually want to use check_unknown_attribute and skip_meta_item when encountering any unknown fields.

Returns Err on any parsing errors or the first failure of func.