Skip to content

Commit

Permalink
Replace FromError with From
Browse files Browse the repository at this point in the history
As per rust-lang/rust#23879.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
  • Loading branch information
andersk committed Apr 2, 2015
1 parent a645c6d commit 331cfa6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ pub enum Error {
Io(io::Error),
}

impl error::FromError<io::Error> for Error {
fn from_error(err: io::Error) -> Error { Error::Io(err) }
impl From<io::Error> for Error {
fn from(err: io::Error) -> Error { Error::Io(err) }
}

impl error::FromError<Error> for io::Error {
fn from_error(err: Error) -> io::Error {
impl From<Error> for io::Error {
fn from(err: Error) -> io::Error {
match err {
Error::Io(err) => err,
Error::UnexpectedEOF => io::Error::new(io::ErrorKind::Other,
Expand Down Expand Up @@ -188,14 +188,14 @@ fn read_full<R: io::Read + ?Sized>(rdr: &mut R, buf: &mut [u8]) -> Result<()> {
Ok(0) => return Err(Error::UnexpectedEOF),
Ok(n) => nread += n,
Err(ref e) if e.kind() == io::ErrorKind::Interrupted => {},
Err(e) => return Err(error::FromError::from_error(e))
Err(e) => return Err(From::from(e))
}
}
Ok(())
}

fn write_all<W: io::Write + ?Sized>(wtr: &mut W, buf: &[u8]) -> Result<()> {
wtr.write_all(buf).map_err(error::FromError::from_error)
wtr.write_all(buf).map_err(From::from)
}

/// Extends `Write` with methods for writing numbers. (For `std::io`.)
Expand Down

0 comments on commit 331cfa6

Please # to comment.