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

Function compile_rule

src/speech.rs:220–234  ·  view source on GitHub ↗

Given a string that should be Yaml, it calls `build_fn` with that string. The build function/closure should process the Yaml as appropriate and capture any errors and write them to `std_err`.

(str: &str, mut build_fn: F)

Source from the content-addressed store, hash-verified

218/// Given a string that should be Yaml, it calls `build_fn` with that string.
219/// The build function/closure should process the Yaml as appropriate and capture any errors and write them to `std_err`.
220pub fn compile_rule<F>(str: &str, mut build_fn: F) -> Result<()> where
221 F: FnMut(&Yaml) -> Result<()> {
222 let docs = YamlLoader::load_from_str(str);
223 match docs {
224 Err(e) => {
225 bail!("Parse error!!: {}", e);
226 },
227 Ok(docs) => {
228 if docs.len() != 1 {
229 bail!("Didn't find rules!");
230 }
231 return build_fn(&docs[0]);
232 }
233 }
234}
235
236fn process_include<F>(current_file: &Path, new_file_name: &str, mut read_new_file: F) -> Result<()>
237 where F: FnMut(&Path) -> Result<()> {

Callers 4

read_patternsMethod · 0.85
read_unicodeMethod · 0.85
test_read_defFunction · 0.85

Calls 1

lenMethod · 0.80

Tested by 1

test_read_defFunction · 0.68