Replace deprecated Error::cause with Error::source

Error::source was added in Rust 1.30.0, and Error::cause was deprecated
in favour of it in Rust 1.33.0.
This commit is contained in:
Oliver Hamlet
2019-06-30 11:25:24 +01:00
parent 860995638c
commit 954757a141
+4 -4
View File
@@ -63,7 +63,7 @@ impl fmt::Display for Error {
} }
impl error::Error for Error { impl error::Error for Error {
fn cause(&self) -> Option<&error::Error> { fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self { match self {
Error::ParsingError(_, e) => Some(e), Error::ParsingError(_, e) => Some(e),
Error::PeParsingError(_, e) => Some(e.as_ref()), Error::PeParsingError(_, e) => Some(e.as_ref()),
@@ -97,8 +97,8 @@ impl<I: fmt::Debug + fmt::Display> fmt::Display for ParsingError<I> {
} }
impl<I: fmt::Debug + fmt::Display> error::Error for ParsingError<I> { impl<I: fmt::Debug + fmt::Display> error::Error for ParsingError<I> {
fn cause(&self) -> Option<&error::Error> { fn source(&self) -> Option<&(dyn error::Error + 'static)> {
self.kind.cause() self.kind.source()
} }
} }
@@ -147,7 +147,7 @@ impl From<ParseIntError> for ParsingErrorKind {
} }
impl error::Error for ParsingErrorKind { impl error::Error for ParsingErrorKind {
fn cause(&self) -> Option<&error::Error> { fn source(&self) -> Option<&(dyn error::Error + 'static)> {
match self { match self {
ParsingErrorKind::InvalidCrc(e) => Some(e), ParsingErrorKind::InvalidCrc(e) => Some(e),
_ => None, _ => None,