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
use crate::ast;
use crate::{Parse, ParseError, Parser, Spanned, ToTokens};
#[derive(Debug, Clone, PartialEq, Eq, ToTokens, Spanned)]
pub enum Condition {
Expr(ast::Expr),
ExprLet(Box<ast::ExprLet>),
}
impl Parse for Condition {
fn parse(p: &mut Parser) -> Result<Self, ParseError> {
Ok(match p.nth(0)? {
K![let] => Self::ExprLet(Box::new(ast::ExprLet::parse_without_eager_brace(p)?)),
_ => Self::Expr(ast::Expr::parse_without_eager_brace(p)?),
})
}
}