From ece8a8f520697be50cbe543bebe065c5198dae4d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 29 Jan 2014 16:33:57 -0800 Subject: std: Remove io::io_error * All I/O now returns IoResult = Result * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd --- src/libstd/io/pipe.rs | 26 ++++---------------------- 1 file changed, 4 insertions(+), 22 deletions(-) (limited to 'src/libstd/io/pipe.rs') diff --git a/src/libstd/io/pipe.rs b/src/libstd/io/pipe.rs index 9919d333f41..34d8bf96aa2 100644 --- a/src/libstd/io/pipe.rs +++ b/src/libstd/io/pipe.rs @@ -14,7 +14,7 @@ //! enough so that pipes can be created to child processes. use prelude::*; -use io::{io_error, EndOfFile}; +use io::IoResult; use libc; use rt::rtio::{RtioPipe, LocalIo}; @@ -42,7 +42,7 @@ impl PipeStream { /// /// If the pipe cannot be created, an error will be raised on the /// `io_error` condition. - pub fn open(fd: libc::c_int) -> Option { + pub fn open(fd: libc::c_int) -> IoResult { LocalIo::maybe_raise(|io| { io.pipe_open(fd).map(|obj| PipeStream { obj: obj }) }) @@ -54,29 +54,11 @@ impl PipeStream { } impl Reader for PipeStream { - fn read(&mut self, buf: &mut [u8]) -> Option { - match self.obj.read(buf) { - Ok(read) => Some(read), - Err(ioerr) => { - // EOF is indicated by returning None - if ioerr.kind != EndOfFile { - io_error::cond.raise(ioerr); - } - return None; - } - } - } + fn read(&mut self, buf: &mut [u8]) -> IoResult { self.obj.read(buf) } } impl Writer for PipeStream { - fn write(&mut self, buf: &[u8]) { - match self.obj.write(buf) { - Ok(_) => (), - Err(ioerr) => { - io_error::cond.raise(ioerr); - } - } - } + fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.obj.write(buf) } } #[cfg(test)] -- cgit 1.4.1-3-g733a5