Hello everyone,

I was cutting and pasting the following example from the std lib docs:

http://static.rust-lang.org/doc/master/std/io/index.html
Iterate over the lines of a file

    use std::io::BufferedReader;
    use std::io::File;

    let path = Path::new("message.txt");
    let mut file = BufferedReader::new(File::open(&path));
    for line in file.lines() {
        print!("{}", line);
    }

.. and I noticed that file.lines() swallows io errors. Given that this code
will probably be copied a bunch by people new to the language (including
me!) I was thinking it might be worth adding a comment to point this out or
changing to remove the source of bugs.

(BTW, thanks for Rust - I'm enjoying following the language and hope to use
it as a safer replacement for C++ for latency sensitive code.)

Cheers,

Phil
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to