dtcs 0.7.0

Reference implementation of the Data Transformation Contract Standard (DTCS)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//! Constant-expression detection.

use crate::analysis::expr::ast::Expr;

#[must_use]
pub fn is_constant(expr: &Expr) -> bool {
    match expr {
        Expr::Literal { .. } => true,
        Expr::FieldRef { .. } => false,
        Expr::Unary { expr, .. } => is_constant(expr),
        Expr::Binary { left, right, .. } => is_constant(left) && is_constant(right),
        Expr::Call { .. } => false,
    }
}