| 14 | } |
| 15 | |
| 16 | pub fn parse(input: TokenStream) -> Result<Args> { |
| 17 | let ref mut input = iter::new(input); |
| 18 | let condition = expr::parse(input)?; |
| 19 | |
| 20 | token::parse_punct(input, ',')?; |
| 21 | if input.peek().is_none() { |
| 22 | return Err(Error::new(Span::call_site(), "expected one or more attrs")); |
| 23 | } |
| 24 | |
| 25 | let const_span = token::parse_optional_keyword(input, "const"); |
| 26 | let then = if let Some(const_span) = const_span { |
| 27 | token::parse_optional_punct(input, ','); |
| 28 | token::parse_end(input)?; |
| 29 | Then::Const(const_span) |
| 30 | } else { |
| 31 | Then::Attribute(input.collect()) |
| 32 | }; |
| 33 | |
| 34 | Ok(Args { condition, then }) |
| 35 | } |