aboutsummaryrefslogtreecommitdiff
path: root/src/pre_process.rs
diff options
context:
space:
mode:
authorjan <jan@ruken.pw>2016-09-30 12:30:31 (UTC)
committerjan <jan@ruken.pw>2016-09-30 12:30:31 (UTC)
commit361ea3a80a60bc6595a7a624b6cc5d71ddc8f6fc (patch)
treef25d133b1ff7cdac720af309144bf6b69eec801f /src/pre_process.rs
parent4ff469246f420c5a91d2a25eab9c21421abd3de9 (diff)
jetzt werden die Sektionen aus einer config.yml rausgezogen.
Diffstat (limited to 'src/pre_process.rs')
-rw-r--r--src/pre_process.rs26
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
26impl Section { 26impl 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
37pub fn split_sections(d: &str, s: &mut Vec<Section>) { 37pub 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 &section.keys { 43 for key in &section.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}