diff options
Diffstat (limited to 'src/pre_process.rs')
-rw-r--r-- | src/pre_process.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/pre_process.rs b/src/pre_process.rs index 0d8c6be..a4d6c14 100644 --- a/src/pre_process.rs +++ b/src/pre_process.rs | |||
@@ -24,14 +24,14 @@ pub struct Section { | |||
24 | } | 24 | } |
25 | 25 | ||
26 | impl Section { | 26 | impl Section { |
27 | pub fn new(name: &str, re: &str, groups: Vec<String>) -> Self { | 27 | pub fn new(name: &str, re: &str, groups: Vec<String>) -> Self { |
28 | Section { | 28 | Section { |
29 | name: name.into(), | 29 | name: name.into(), |
30 | re: Regex::new(re).unwrap(), | 30 | re: Regex::new(re).unwrap(), |
31 | keys: groups, | 31 | keys: groups, |
32 | data: HashMap::new(), | 32 | data: HashMap::new(), |
33 | } | 33 | } |
34 | } | 34 | } |
35 | } | 35 | } |
36 | 36 | ||
37 | pub fn split_sections(d: &str, s: &mut Vec<Section>) { | 37 | pub fn split_sections(d: &str, s: &mut Vec<Section>) { |
@@ -39,11 +39,11 @@ pub fn split_sections(d: &str, s: &mut Vec<Section>) { | |||
39 | for m in section.re.captures_iter(d) { | 39 | for m in section.re.captures_iter(d) { |
40 | assert!(m.len() >= section.keys.len() + 1); | 40 | assert!(m.len() >= section.keys.len() + 1); |
41 | 41 | ||
42 | let mut idx = 0; | 42 | let mut idx = 0; |
43 | for key in §ion.keys { | 43 | for key in §ion.keys { |
44 | section.data.insert(key.clone(), m.at(idx + 1).unwrap().into()); | 44 | section.data.insert(key.clone(), m.at(idx + 1).unwrap().into()); |
45 | idx += 1; | 45 | idx += 1; |
46 | } | 46 | } |
47 | } | 47 | } |
48 | } | 48 | } |
49 | } | 49 | } |