Improve efficiency with manual YAML operations

This commit is contained in:
Paul Hauner
2019-05-15 17:14:28 +10:00
parent 63ee179def
commit c6fa1602de
3 changed files with 51 additions and 23 deletions

View File

@@ -22,3 +22,14 @@ pub fn yaml_to_string(yaml: &Yaml) -> String {
out_str
}
pub fn yaml_split_header_and_cases(mut yaml: String) -> (String, String) {
let test_cases_start = yaml.find("\ntest_cases:\n").unwrap();
// + 1 to skip the \n we used for matching.
let mut test_cases = yaml.split_off(test_cases_start + 1);
let end_of_first_line = test_cases.find("\n").unwrap();
let test_cases = test_cases.split_off(end_of_first_line + 1);
(yaml, test_cases)
}