mozilla/rust — pull request #9888 by alexcrichton (2013-10-16 05:48:25+00:00)
Title: Remove even more of std::io

This will be ready for merging soon, but I wanted to solicit for some opinions about the changes here. I'm unhappy about the diff stat being positive, although it's not too largely so in this case. Currently most of the increase in verbosity is from being forced to use `@mut io::{Writer, Reader}` instead of using `&mut io::Writer` which is more well-supported (especially when writing to an array of bytes). This I don't think can be helped much (without other refactorings).

I was curious what others thought about the usage of the file I/O right now, though. Things I noticed:

* Every argument to `open_reader` was `io::Open`, and every argument to `open_writer` was `io::CreateOrTruncate` except maybe one or two.
* Using `open_reader` and `open_writer` requires at least two imports: `std::rt::io` and `std::rt::io::file::FileInfo`.
* Using `MemReader` usefully also requires two imports: `std::rt::io::mem::{MemReader, MemWriter}`, and `std::rt::io::Decorator`
* Having `Reader` and `Writer` defined on `Option` is awesome. Once I realized that was true, I started making code a lot smaller.
* There's one location where I have to catch on both the `io_error` and `read_error` conditions. This seems wrong?

I'm not sure if these intend to be added to the prelude, but it is a bit unfortunate if they had to be in the prelude to make these nicer to use. I'm personally in favor of `File::open` and `File::create` with default arguments to `open_reader` and `open_writer` respectively because that's what you want 90% of the time.