From d55bbf150f739bc9e18c3d5bf953f36728889286 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lena=20Hellstr=C3=B6m?= Date: Tue, 18 Jul 2017 21:54:23 -0700 Subject: [PATCH] Remove naming redundancy with IoError --- src/de/read.rs | 2 +- src/internal.rs | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/de/read.rs b/src/de/read.rs index c22ee23..048cba2 100644 --- a/src/de/read.rs +++ b/src/de/read.rs @@ -61,7 +61,7 @@ impl IoRead for IoReadReader { impl <'storage> SliceReader<'storage> { fn unexpected_eof() -> Box<::ErrorKind> { - return Box::new(::ErrorKind::IoError(IoError::new(IoErrorKind::UnexpectedEof, ""))); + return Box::new(::ErrorKind::Io(IoError::new(IoErrorKind::UnexpectedEof, ""))); } } diff --git a/src/internal.rs b/src/internal.rs index d8aa74e..2584598 100644 --- a/src/internal.rs +++ b/src/internal.rs @@ -34,7 +34,7 @@ pub type Error = Box; pub enum ErrorKind { /// If the error stems from the reader/writer that is being used /// during (de)serialization, that error will be stored and returned here. - IoError(IoError), + Io(IoError), /// If the bytes in the reader are not decodable because of an invalid /// encoding, this error will be returned. This error is only possible /// if a stream is corrupted. A stream produced from `encode` or `encode_into` @@ -57,7 +57,7 @@ pub enum ErrorKind { impl error::Error for ErrorKind { fn description(&self) -> &str { match *self { - ErrorKind::IoError(ref err) => error::Error::description(err), + ErrorKind::Io(ref err) => error::Error::description(err), ErrorKind::InvalidEncoding{desc, ..} => desc, ErrorKind::SequenceMustHaveLength => "bincode can't encode infinite sequences", ErrorKind::SizeLimit => "the size limit for decoding has been reached", @@ -68,7 +68,7 @@ impl error::Error for ErrorKind { fn cause(&self) -> Option<&error::Error> { match *self { - ErrorKind::IoError(ref err) => err.cause(), + ErrorKind::Io(ref err) => err.cause(), ErrorKind::InvalidEncoding{..} => None, ErrorKind::SequenceMustHaveLength => None, ErrorKind::SizeLimit => None, @@ -79,16 +79,16 @@ impl error::Error for ErrorKind { impl From for Error { fn from(err: IoError) -> Error { - ErrorKind::IoError(err).into() + ErrorKind::Io(err).into() } } impl fmt::Display for ErrorKind { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { match *self { - ErrorKind::IoError(ref ioerr) => - write!(fmt, "IoError: {}", ioerr), - ErrorKind::InvalidEncoding{desc, detail: None}=> + ErrorKind::Io(ref ioerr) => + write!(fmt, "Io: {}", ioerr), + ErrorKind::InvalidEncoding{desc, detail: None}=> write!(fmt, "InvalidEncoding: {}", desc), ErrorKind::InvalidEncoding{desc, detail: Some(ref detail)}=> write!(fmt, "InvalidEncoding: {} ({})", desc, detail), @@ -201,7 +201,7 @@ pub fn serialized_size_bounded(value: &T, max: u64) -> Option where T: serde::Serialize { let mut size_counter = SizeChecker { - size_limit: CountSize { total: 0, limit: Some(max) } + size_limit: CountSize { total: 0, limit: Some(max) } }; match value.serialize(&mut size_counter) {