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)
| 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`. |
| 220 | pub 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 | |
| 236 | fn process_include<F>(current_file: &Path, new_file_name: &str, mut read_new_file: F) -> Result<()> |
| 237 | where F: FnMut(&Path) -> Result<()> { |