| 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. |