Skip to content

Commit e314c6c

Browse files
authored
Merge pull request #1742 from mfasold/patch-1
Update read_lines example to flatten iterator
2 parents 2734c6c + 7a95f76 commit e314c6c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/std_misc/file/read_lines.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,8 @@ 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 {
60-
if let Ok(ip) = line {
61-
println!("{}", ip);
62-
}
59+
for line in lines.flatten() {
60+
println!("{}", line);
6361
}
6462
}
6563
}

0 commit comments

Comments
 (0)