std: Remove io::io_error

* All I/O now returns IoResult<T> = Result<T, IoError>
* All formatting traits now return fmt::Result = IoResult<()>
* The if_ok!() macro was added to libstd
This commit is contained in:
Alex Crichton
2014-01-29 16:33:57 -08:00
parent be4fc63809
commit ece8a8f520
35 changed files with 918 additions and 1059 deletions

View File

@@ -11,10 +11,12 @@
use container::Container;
use fmt;
use from_str::FromStr;
use io::IoResult;
use iter::Iterator;
use libc;
use option::{Some, None, Option};
use os;
use result::Ok;
use str::StrSlice;
use unstable::running_on_valgrind;
use vec::ImmutableVector;
@@ -73,16 +75,17 @@ pub fn dumb_println(args: &fmt::Arguments) {
struct Stderr;
impl io::Writer for Stderr {
fn write(&mut self, data: &[u8]) {
fn write(&mut self, data: &[u8]) -> IoResult<()> {
unsafe {
libc::write(libc::STDERR_FILENO,
data.as_ptr() as *libc::c_void,
data.len() as libc::size_t);
}
Ok(()) // yes, we're lying
}
}
let mut w = Stderr;
fmt::writeln(&mut w as &mut io::Writer, args);
let _ = fmt::writeln(&mut w as &mut io::Writer, args);
}
pub fn abort(msg: &str) -> ! {