Browse Source

less mutability

boyska 4 years ago
parent
commit
a953bf22ec
1 changed files with 4 additions and 3 deletions
  1. 4 3
      src/main.rs

+ 4 - 3
src/main.rs

@@ -12,15 +12,16 @@ fn main() {
     let fname = &args[1];
     let regexp = &args[2];
 
-    let w = vec![];
-    let mut d = Dictionary{words: w};
+    let mut w = vec![];
     let f = File::open(fname).unwrap();
     let buf = BufReader::new(&f);
     for line in buf.lines() {
         let line = line.unwrap();
         // TODO: normalizza: lascia solo a-z, converti gli accenti, ecc.
-        d.words.push(line.to_string())
+        w.push(line.to_string())
     } 
+
+    let d = Dictionary{words: w};
     let re = Regex::new(regexp).unwrap();
     for w in &d.words {
         if re.is_match(w) {