1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
pub(crate) mod restructure;
mod validation;
use std::fmt::Formatter;
use syn::braced;
use syn::parse::{Parse, ParseStream, Result};
use syn::punctuated::Punctuated;
#[derive(Clone)]
pub(crate) struct AttributeArgList {
pub(crate) args: Punctuated<IdentifiedArgList, Token![,]>,
}
impl Parse for AttributeArgList {
fn parse(input: ParseStream) -> Result<Self> {
Ok(AttributeArgList {
args: Punctuated::parse_terminated(input)?,
})
}
}
#[derive(Clone)]
pub(crate) struct IdentifiedArgList {
pub(crate) id: syn::Ident,
assignment: Token![=],
braces: syn::token::Brace,
pub(crate) param_args: Punctuated<syn::Expr, Token![,]>,
}
impl std::fmt::Debug for IdentifiedArgList {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
f.write_str(&format!("IdentifiedArgList(id = {:?})", self.id))
}
}
impl Parse for IdentifiedArgList {
fn parse(input: ParseStream) -> Result<Self> {
let content;
Ok(IdentifiedArgList {
id: input.parse()?,
assignment: input.parse()?,
braces: braced!(content in input),
param_args: Punctuated::parse_terminated(&content)?,
})
}
}