rscel 1.0.8

Cel interpreter in rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crate::interp::Interpreter;
use crate::types::CelByteCode;
use crate::{CelError, CelValue};

pub fn has_impl(ctx: &Interpreter, _this: CelValue, exprlist: &[&CelByteCode]) -> CelValue {
    if exprlist.len() != 1 {
        return CelValue::from_err(CelError::argument("has() macro expects exactly 1 argument"));
    }

    match ctx.run_raw(&exprlist[0], true) {
        Ok(_) => CelValue::true_(),
        Err(err) => match err {
            CelError::Binding { .. } | CelError::Attribute { .. } => CelValue::false_(),
            other => CelValue::from_err(other),
        },
    }
}