I think the following documentations describe this behavior pretty well. http://static.rust-lang.org/doc/master/std/io/trait.Buffer.html#method.lines http://static.rust-lang.org/doc/master/std/io/struct.Lines.html
As the documentation puts, this behavior is intentional as it would be annoying for casual uses otherwise. 2014-02-18 17:16 GMT+09:00 Phil Dawes <[email protected]>: > 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 > [email protected] > https://mail.mozilla.org/listinfo/rust-dev > -- -- Kang Seonghoon | Software Engineer, iPlateia Inc. | http://mearie.org/ -- Opinions expressed in this email do not necessarily represent the views of my employer. -- _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
