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

Method add_variable

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

Source from the content-addressed store, hash-verified

48
49impl<'a> Context<'a> {
50 pub fn add_variable<S, V>(
51 &mut self,
52 name: S,
53 value: V,
54 ) -> Result<(), <V as TryIntoValue>::Error>
55 where
56 S: Into<String>,
57 V: TryIntoValue,
58 {
59 match self {
60 Context::Root { variables, .. } => {
61 let value = value.try_into_value()?;
62 let value: Box<dyn Val> = value.try_into().unwrap();
63 variables.insert(name.into(), value);
64 }
65 Context::Child { variables, .. } => {
66 let value = value.try_into_value()?;
67 let value: Box<dyn Val> = value.try_into().unwrap();
68 variables.insert(name.into(), value);
69 }
70 }
71 Ok(())
72 }
73
74 pub fn add_variable_from_value<S, V>(&mut self, name: S, value: V)
75 where

Callers 15

mainFunction · 0.80
mainFunction · 0.80
mainFunction · 0.80
test_unitFunction · 0.80
test_newtypeFunction · 0.80
test_optionsFunction · 0.80
test_tuplesFunction · 0.80
test_structsFunction · 0.80
test_time_typesFunction · 0.80
test_timestamp_variableFunction · 0.80
test_size_fn_varFunction · 0.80

Calls 2

try_into_valueMethod · 0.80
try_intoMethod · 0.80

Tested by 14

test_unitFunction · 0.64
test_newtypeFunction · 0.64
test_optionsFunction · 0.64
test_tuplesFunction · 0.64
test_structsFunction · 0.64
test_time_typesFunction · 0.64
test_timestamp_variableFunction · 0.64
test_size_fn_varFunction · 0.64
out_of_bound_list_accessFunction · 0.64
list_access_uintFunction · 0.64