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

Method replace_array_tree

src/speech.rs:865–879  ·  view source on GitHub ↗
(&self, rules_with_context: &'r mut SpeechRulesWithContext<'c, 's,'m>, mathml: Element<'c>)

Source from the content-addressed store, hash-verified

863 }
864
865 pub fn replace_array_tree<'c, 's:'c, 'm:'c>(&self, rules_with_context: &'r mut SpeechRulesWithContext<'c, 's,'m>, mathml: Element<'c>) -> Result<Element<'m>> {
866 // shortcut for common case (don't build a new tree node)
867 if self.replacements.len() == 1 {
868 return rules_with_context.replace::<Element<'m>>(&self.replacements[0], mathml);
869 }
870
871 let new_element = create_mathml_element(&rules_with_context.doc, "Unknown"); // Hopefully set later (in Intent::Replace())
872 let mut new_children = Vec::with_capacity(self.replacements.len());
873 for child in self.replacements.iter() {
874 let child = rules_with_context.replace::<Element<'m>>(child, mathml)?;
875 new_children.push(ChildOfElement::Element(child));
876 };
877 new_element.append_children(new_children);
878 return Ok(new_element);
879 }
880
881
882 /// Return true if there are no replacements.

Callers 1

replaceMethod · 0.80

Calls 3

create_mathml_elementFunction · 0.85
lenMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected