From 7a95f766d52d8749756ff3bef2b5ebc325a812cb Mon Sep 17 00:00:00 2001 From: Mario Fasold Date: Thu, 14 Sep 2023 11:38:52 +0200 Subject: [PATCH] Update read_lines to flatten iterator Clippy complains about manual flatten, see https://rust-lang.github.io/rust-clippy/master/index.html#/manual_flatten --- src/std_misc/file/read_lines.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/std_misc/file/read_lines.md b/src/std_misc/file/read_lines.md index 216b0181c5..a6f330094e 100644 --- a/src/std_misc/file/read_lines.md +++ b/src/std_misc/file/read_lines.md @@ -56,10 +56,8 @@ 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 { - if let Ok(ip) = line { - println!("{}", ip); - } + for line in lines.flatten() { + println!("{}", line); } } }