1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use syn::{
    parse::{self, Parse, ParseStream},
    punctuated::Punctuated,
    Expr, LitStr, Token,
};

pub(crate) struct Args {
    pub(crate) format_string: LitStr,
    pub(crate) formatting_args: Option<Punctuated<Expr, Token![,]>>,
}

impl Parse for Args {
    fn parse(input: ParseStream) -> parse::Result<Self> {
        Ok(Self {
            format_string: input.parse()?,
            formatting_args: if input.is_empty() {
                None
            } else {
                let _comma: Token![,] = input.parse()?;
                Some(Punctuated::parse_terminated(input)?)
            },
        })
    }
}