On Tue, Feb 18, 2014 at 11:52 PM, Phil Dawes <[email protected]> wrote:
> Is that not a big problem for production code? I think I'd prefer the > default case to be to crash the task than deal with a logic bug. > > The existence of library functions that swallow errors makes reviewing > code and reasoning about failure cases a lot more difficult. > There are other methods that allow one to read lines and handle error cases. `Lines` is a convenience method by design. > On Tue, Feb 18, 2014 at 11:02 AM, Kang Seonghoon <[email protected]>wrote: > >> 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 > >
_______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
