| 1 | use syn::{ |
| 2 | parse::{self, Parse, ParseStream}, |
| 3 | Expr, Token, |
| 4 | }; |
| 5 | |
| 6 | use super::log; |
| 7 | |
| 8 | pub(crate) mod assert; |
| 9 | pub(crate) mod unwrap; |
| 10 | |
| 11 | struct Args { |
| 12 | condition: Expr, |
| 13 | log_args: Option<log::Args>, |
| 14 | } |
| 15 | |
| 16 | impl Parse for Args { |
| 17 | fn parse(input: ParseStream) -> parse::Result<Self> { |
| 18 | let condition = input.parse()?; |
| 19 | if input.is_empty() { |
| 20 | // assert!(a) |
| 21 | return Ok(Args { |
| 22 | log_args: None, |
| 23 | condition, |
| 24 | }); |
| 25 | } |
| 26 | |
| 27 | let _comma: Token![,] = input.parse()?; |
| 28 | |
| 29 | if input.is_empty() { |
| 30 | // assert!(a,) |
| 31 | Ok(Args { |
| 32 | log_args: None, |
| 33 | condition, |
| 34 | }) |
| 35 | } else { |
| 36 | // assert!(a, "b", c) |
| 37 | Ok(Args { |
| 38 | log_args: Some(input.parse()?), |
| 39 | condition, |
| 40 | }) |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |