less mutability

This commit is contained in:
boyska 2020-05-18 12:56:19 +02:00
parent 30d1d94a68
commit a953bf22ec

View file

@ -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) {