MCPcopy Create free account
hub / github.com/daisy/MathCAT / set_globals

Method set_globals

src/speech.rs:1632–1644  ·  view source on GitHub ↗
(&'r mut self, new_vars: VariableDefinitions, mathml: Element<'c>)

Source from the content-addressed store, hash-verified

1630 }
1631
1632 fn set_globals(&'r mut self, new_vars: VariableDefinitions, mathml: Element<'c>) -> Result<()> {
1633 // for each var/value pair, evaluate the value and add the var/value to the base context
1634 for def in &new_vars.defs {
1635 // set the new value
1636 let new_value = match def.value.evaluate(&self.base, mathml) {
1637 Ok(val) => val,
1638 Err(_) => bail!(format!("Can't evaluate variable def for {}", def)),
1639 };
1640 let qname = QName::new(def.name.as_str());
1641 self.base.set_variable(qname, new_value);
1642 }
1643 return Ok( () );
1644 }
1645
1646 fn push(&'r mut self, new_vars: VariableDefinitions, mathml: Element<'c>) -> Result<()> {
1647 // store the old value and set the new one

Callers 1

replaceMethod · 0.80

Calls 2

as_strMethod · 0.80
evaluateMethod · 0.45

Tested by

no test coverage detected