Skip to content

Commit 69c0e9b

Browse files
authored
Merge pull request #1890 from lgarron/patch-1
`read_lines`: Use `.map_while(Result::ok)` instead of `.flatten()`.
2 parents 8bede1b + 04fb7f3 commit 69c0e9b

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)