Skip to content

Commit

Permalink
read_lines: Use . filter_map(Result::ok) instead of .flatten().
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarron authored Oct 17, 2024
1 parent 8bede1b commit 04fb7f3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/std_misc/file/read_lines.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn main() {
// File hosts.txt must exist in the current path
if let Ok(lines) = read_lines("./hosts.txt") {
// Consumes the iterator, returns an (Optional) String
for line in lines.flatten() {
for line in lines.map_while(Result::ok) {
println!("{}", line);
}
}
Expand Down

0 comments on commit 04fb7f3

Please sign in to comment.