Remove unused Simple io error variant

This commit is contained in:
David Tolnay 2020-01-21 23:41:52 -08:00
parent f063631c0a
commit 5741cfb44a
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -10,24 +10,11 @@ pub enum ErrorKind {
UnexpectedEof, UnexpectedEof,
} }
impl ErrorKind {
#[inline]
fn as_str(&self) -> &'static str {
match self {
ErrorKind::InvalidData => "invalid data",
ErrorKind::WriteZero => "write zero",
ErrorKind::Other => "other os error",
ErrorKind::UnexpectedEof => "unexpected end of file",
}
}
}
pub struct Error { pub struct Error {
repr: Repr, repr: Repr,
} }
enum Repr { enum Repr {
Simple(ErrorKind),
Custom(ErrorKind, Box<dyn Display + Send + Sync>), Custom(ErrorKind, Box<dyn Display + Send + Sync>),
} }
@ -35,7 +22,6 @@ impl Display for Error {
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.repr { match &self.repr {
Repr::Custom(_, msg) => write!(fmt, "{}", msg), Repr::Custom(_, msg) => write!(fmt, "{}", msg),
Repr::Simple(kind) => write!(fmt, "{}", kind.as_str()),
} }
} }
} }
@ -48,15 +34,6 @@ impl Debug for Error {
impl serde::de::StdError for Error {} impl serde::de::StdError for Error {}
impl From<ErrorKind> for Error {
#[inline]
fn from(kind: ErrorKind) -> Error {
Error {
repr: Repr::Simple(kind),
}
}
}
impl Error { impl Error {
pub(crate) fn new<E>(kind: ErrorKind, error: E) -> Error pub(crate) fn new<E>(kind: ErrorKind, error: E) -> Error
where where