rune/ast/
utils.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::ast;

/// Test if the given expression qualifieis as a block end or not, as with a
/// body in a match expression.
///
/// This determines if a comma is necessary or not after the expression.
pub(crate) fn is_block_end(expr: &ast::Expr, comma: Option<&T![,]>) -> bool {
    match (expr, comma) {
        (ast::Expr::Block(..), _) => false,
        (ast::Expr::For(..), _) => false,
        (ast::Expr::While(..), _) => false,
        (ast::Expr::If(..), _) => false,
        (ast::Expr::Match(..), _) => false,
        (_, Some(..)) => false,
        (_, None) => true,
    }
}