| 1 | use syn::{ |
| 2 | parse::{self, Parse, ParseStream}, |
| 3 | punctuated::Punctuated, |
| 4 | Expr, LitStr, Token, |
| 5 | }; |
| 6 | |
| 7 | pub(crate) struct Args { |
| 8 | pub(crate) format_string: LitStr, |
| 9 | pub(crate) formatting_args: Option<Punctuated<Expr, Token![,]>>, |
| 10 | } |
| 11 | |
| 12 | impl Parse for Args { |
| 13 | fn parse(input: ParseStream) -> parse::Result<Self> { |
| 14 | Ok(Self { |
| 15 | format_string: input.parse()?, |
| 16 | formatting_args: if input.is_empty() { |
| 17 | None |
| 18 | } else { |
| 19 | let _comma: Token![,] = input.parse()?; |
| 20 | Some(Punctuated::parse_terminated(input)?) |
| 21 | }, |
| 22 | }) |
| 23 | } |
| 24 | } |
| 25 | |