Register a new definition of a user variable. The type of the value must be the same as the type registered for the variable.
(&mut self, var: Variable, val: Value)
| 505 | /// Register a new definition of a user variable. The type of the value must be |
| 506 | /// the same as the type registered for the variable. |
| 507 | pub fn def_var(&mut self, var: Variable, val: Value) { |
| 508 | self.try_def_var(var, val) |
| 509 | .unwrap_or_else(|error| match error { |
| 510 | DefVariableError::TypeMismatch(var, val) => { |
| 511 | panic!("declared type of variable {var:?} doesn't match type of value {val}"); |
| 512 | } |
| 513 | DefVariableError::DefinedBeforeDeclared(var) => { |
| 514 | panic!("variable {var:?} is used but its type has not been declared"); |
| 515 | } |
| 516 | }) |
| 517 | } |
| 518 | |
| 519 | /// Set label for [`Value`] |
| 520 | /// |