From 04fb7f316efc3f841bc48bf5c86a955f5960d72d Mon Sep 17 00:00:00 2001 From: Lucas Garron Date: Wed, 16 Oct 2024 19:37:22 -0700 Subject: [PATCH] `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 --- src/std_misc/file/read_lines.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/std_misc/file/read_lines.md b/src/std_misc/file/read_lines.md index 7f186d4714..837bac3be7 100644 --- a/src/std_misc/file/read_lines.md +++ b/src/std_misc/file/read_lines.md @@ -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); } }