Skip to main content

hello/
hello.rs

1//! Minimal CEL example.
2//!
3//! Run with: cargo run -p cel-core --example hello
4
5use cel_core::{CelType, Env, MapActivation};
6
7fn main() {
8    let env = Env::with_standard_library().with_variable("name", CelType::String);
9
10    let ast = env.compile(r#""Hello, " + name + "!""#).unwrap();
11    let program = env.program(&ast).unwrap();
12
13    let mut activation = MapActivation::new();
14    activation.insert("name", "World");
15
16    let result = program.eval(&activation);
17    println!("{}", result);
18}