Skip to content

Commit

Permalink
Stop reading file after first error to prevent infinite error loop in…
Browse files Browse the repository at this point in the history
… filter_map
  • Loading branch information
triarius committed Jul 23, 2023
1 parent 4af26b0 commit 8d9b1a1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/words.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn words_from_file(path: impl AsRef<Path>) -> Result<Vec<String>> {
let file = File::open(path)?;
Ok(BufReader::new(file)
.lines()
.filter_map(|l| l.ok())
.map_while(|l| l.ok())
.filter(|w| RE.is_match(w))
.collect())
}

0 comments on commit 8d9b1a1

Please sign in to comment.