MCPcopy Create free account
hub / github.com/cel-rust/cel-rust / main

Function main

example/src/threads.rs:4–23  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2use std::thread::scope;
3
4fn main() {
5 let program = Program::compile("a + b").unwrap();
6
7 scope(|scope| {
8 scope.spawn(|| {
9 let mut context = Context::default();
10 context.add_variable("a", 1).unwrap();
11 context.add_variable("b", 2).unwrap();
12 let value = program.execute(&context).unwrap();
13 assert_eq!(value, 3.into());
14 });
15 scope.spawn(|| {
16 let mut context = Context::default();
17 context.add_variable("a", 2).unwrap();
18 context.add_variable("b", 4).unwrap();
19 let value = program.execute(&context).unwrap();
20 assert_eq!(value, 6.into());
21 });
22 });
23}

Callers

nothing calls this directly

Calls 2

add_variableMethod · 0.80
executeMethod · 0.80

Tested by

no test coverage detected