Skip to content

Commit 04fb7f3

Browse files
authored
read_lines: Use . filter_map(Result::ok) instead of .flatten().
Clippy gives a warning when using `.flatten()`: https://rust-lang.github.io/rust-clippy/master/index.html#lines_filter_map_ok
1 parent 8bede1b commit 04fb7f3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/std_misc/file/read_lines.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ fn main() {
5656
// File hosts.txt must exist in the current path
5757
if let Ok(lines) = read_lines("./hosts.txt") {
5858
// Consumes the iterator, returns an (Optional) String
59-
for line in lines.flatten() {
59+
for line in lines.map_while(Result::ok) {
6060
println!("{}", line);
6161
}
6262
}

0 commit comments

Comments
 (0)