1use rusty_yaml::Yaml;
2
3pub fn unwrap<S: ToString>(yaml: &Yaml, section: S) -> String {
7 let result = yaml
8 .get_section(section.to_string())
9 .unwrap()
10 .nth(0)
11 .to_string();
12
13 let first = match result.chars().nth(0) {
14 Some(v) => v,
15 None => ' ',
16 };
17 let last = match result.chars().nth(result.len() - 1) {
18 Some(v) => v,
19 None => ' ',
20 };
21 if first == last {
22 match first {
23 '\'' | '"' => result[1..result.len() - 1].to_string(),
26 _ => result.to_string(),
27 }
28 } else {
29 result.to_string()
30 }
31}
32
33pub fn unmatched_quotes(yaml: &Yaml) -> Option<String> {
36 for line in yaml.to_string().lines() {
37 if line.matches('"').count() % 2 != 0 {
38 return Some(line.to_string());
39 }
40 }
41 None
42}