less mutability
This commit is contained in:
parent
30d1d94a68
commit
a953bf22ec
1 changed files with 4 additions and 3 deletions
|
@ -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) {
|
||||
|
|
Reference in a new issue