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

Method add_variable_from_value

cel/src/context.rs:74–91  ·  view source on GitHub ↗
(&mut self, name: S, value: V)

Source from the content-addressed store, hash-verified

72 }
73
74 pub fn add_variable_from_value<S, V>(&mut self, name: S, value: V)
75 where
76 S: Into<String>,
77 V: Into<Value>,
78 {
79 match self {
80 Context::Root { variables, .. } => {
81 let value = value.into();
82 let value: Box<dyn Val> = value.try_into().unwrap();
83 variables.insert(name.into(), value);
84 }
85 Context::Child { variables, .. } => {
86 let value = value.into();
87 let value: Box<dyn Val> = value.try_into().unwrap();
88 variables.insert(name.into(), value);
89 }
90 }
91 }
92
93 /// Binds a variable to a custom [`Val`] implementation directly, without
94 /// going through the [`Value`] enum.

Callers 15

todo_is_allowedMethod · 0.80
criterion_benchmarkFunction · 0.80
map_macro_benchmarkFunction · 0.80
assert_outputFunction · 0.80
test_execution_errorsFunction · 0.80
test_hasFunction · 0.80
test_indexed_map_accessFunction · 0.80
test_numeric_map_accessFunction · 0.80
test_short_circuit_andFunction · 0.80

Calls 1

try_intoMethod · 0.80

Tested by 11

test_execution_errorsFunction · 0.64
test_hasFunction · 0.64
test_indexed_map_accessFunction · 0.64
test_numeric_map_accessFunction · 0.64
test_short_circuit_andFunction · 0.64
test_opaque_fnFunction · 0.64
opaque_eqFunction · 0.64
test_optionalFunction · 0.64