Update to new (io::)Error

This commit is contained in:
Mathijs van de Nes 2015-04-02 20:50:50 +02:00
parent 4842d19dc9
commit 80fd4b6dcf
4 changed files with 10 additions and 10 deletions

View file

@ -95,7 +95,7 @@ impl<R: Read> Read for Crc32Reader<R>
{
let count = match self.inner.read(buf)
{
Ok(0) if !self.check_matches() => { return Err(io::Error::new(io::ErrorKind::Other, "Invalid checksum", None)) },
Ok(0) if !self.check_matches() => { return Err(io::Error::new(io::ErrorKind::Other, "Invalid checksum")) },
Ok(n) => n,
Err(e) => return Err(e),
};

View file

@ -3,7 +3,7 @@
#![feature(unsafe_destructor)]
#![warn(missing_docs)]
#![feature(io, convert, step_by)]
#![feature(step_by)]
extern crate time;
extern crate flate2;

View file

@ -28,7 +28,7 @@ impl ZipError
{
fn detail(&self) -> ::std::borrow::Cow<str>
{
use ::std::error::Error;
use std::error::Error;
match *self
{
@ -45,9 +45,9 @@ impl ZipError
}
}
impl error::FromError<io::Error> for ZipError
impl ::std::convert::From<io::Error> for ZipError
{
fn from_error(err: io::Error) -> ZipError
fn from(err: io::Error) -> ZipError
{
ZipError::Io(err)
}

View file

@ -69,12 +69,12 @@ impl<W: Write+io::Seek> Write for ZipWriter<W>
{
fn write(&mut self, buf: &[u8]) -> io::Result<usize>
{
if self.files.len() == 0 { return Err(io::Error::new(io::ErrorKind::Other, "No file has been started", None)) }
if self.files.len() == 0 { return Err(io::Error::new(io::ErrorKind::Other, "No file has been started")) }
self.stats.update(buf);
match self.inner.ref_mut()
{
Some(ref mut w) => w.write(buf),
None => Err(io::Error::new(io::ErrorKind::BrokenPipe, "ZipWriter was already closed", None)),
None => Err(io::Error::new(io::ErrorKind::BrokenPipe, "ZipWriter was already closed")),
}
}
@ -83,7 +83,7 @@ impl<W: Write+io::Seek> Write for ZipWriter<W>
match self.inner.ref_mut()
{
Some(ref mut w) => w.flush(),
None => Err(io::Error::new(io::ErrorKind::BrokenPipe, "ZipWriter was already closed", None)),
None => Err(io::Error::new(io::ErrorKind::BrokenPipe, "ZipWriter was already closed")),
}
}
}
@ -233,7 +233,7 @@ impl<W: Write+io::Seek> GenericZipWriter<W>
{
match self.current_compression() {
Some(method) if method == compression => return Ok(()),
None => try!(Err(io::Error::new(io::ErrorKind::BrokenPipe, "ZipWriter was already closed", None))),
None => try!(Err(io::Error::new(io::ErrorKind::BrokenPipe, "ZipWriter was already closed"))),
_ => {},
}
@ -242,7 +242,7 @@ impl<W: Write+io::Seek> GenericZipWriter<W>
GenericZipWriter::Storer(w) => w,
GenericZipWriter::Deflater(w) => try!(w.finish()),
GenericZipWriter::Bzip2(w) => match w.into_inner() { Ok(r) => r, Err((_, err)) => try!(Err(err)) },
GenericZipWriter::Closed => try!(Err(io::Error::new(io::ErrorKind::BrokenPipe, "ZipWriter was already closed", None))),
GenericZipWriter::Closed => try!(Err(io::Error::new(io::ErrorKind::BrokenPipe, "ZipWriter was already closed"))),
};
*self = match compression