From d5d32ecac6482ee1bf24c12092e0d7b6d29a5f70 Mon Sep 17 00:00:00 2001 From: eldesh Date: Wed, 18 Dec 2019 15:26:04 +0900 Subject: [PATCH 1/3] Impl: source method for openssl error --- src/imp/openssl.rs | 7 +++++++ src/lib.rs | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/src/imp/openssl.rs b/src/imp/openssl.rs index cc83f2e6..93c44329 100644 --- a/src/imp/openssl.rs +++ b/src/imp/openssl.rs @@ -133,6 +133,13 @@ impl error::Error for Error { Error::Ssl(ref e, _) => error::Error::cause(e), } } + + fn source(&self) -> Option<&error::Error + 'static> { + match *self { + Error::Normal(ref e) => Some(e), + Error::Ssl(ref e, _) => Some(e), + } + } } impl fmt::Display for Error { diff --git a/src/lib.rs b/src/lib.rs index 34f3fa0a..6a4c0433 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -139,6 +139,10 @@ impl error::Error for Error { fn cause(&self) -> Option<&error::Error> { error::Error::cause(&self.0) } + + fn source(&self) -> Option<&error::Error + 'static> { + error::Error::source(&self.0) + } } impl fmt::Display for Error { From b7edc59d5bc7b8f2624e121fadfb0b9a3ac7ef64 Mon Sep 17 00:00:00 2001 From: eldesh Date: Wed, 18 Dec 2019 16:53:00 +0900 Subject: [PATCH 2/3] Add: 'dyn' annotation --- src/imp/openssl.rs | 4 ++-- src/lib.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/imp/openssl.rs b/src/imp/openssl.rs index 93c44329..3cff788c 100644 --- a/src/imp/openssl.rs +++ b/src/imp/openssl.rs @@ -127,14 +127,14 @@ impl error::Error for Error { } } - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { match *self { Error::Normal(ref e) => error::Error::cause(e), Error::Ssl(ref e, _) => error::Error::cause(e), } } - fn source(&self) -> Option<&error::Error + 'static> { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { match *self { Error::Normal(ref e) => Some(e), Error::Ssl(ref e, _) => Some(e), diff --git a/src/lib.rs b/src/lib.rs index 6a4c0433..e1902466 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -136,11 +136,11 @@ impl error::Error for Error { error::Error::description(&self.0) } - fn cause(&self) -> Option<&error::Error> { + fn cause(&self) -> Option<&dyn error::Error> { error::Error::cause(&self.0) } - fn source(&self) -> Option<&error::Error + 'static> { + fn source(&self) -> Option<&(dyn error::Error + 'static)> { error::Error::source(&self.0) } } From 92432c9fbc9d4ee675f1bd79a03bc053eb36bdf8 Mon Sep 17 00:00:00 2001 From: eldesh Date: Wed, 25 Dec 2019 13:40:09 +0900 Subject: [PATCH 3/3] remove: cause implementation --- src/imp/openssl.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/imp/openssl.rs b/src/imp/openssl.rs index 3cff788c..9dfc4b74 100644 --- a/src/imp/openssl.rs +++ b/src/imp/openssl.rs @@ -127,13 +127,6 @@ impl error::Error for Error { } } - fn cause(&self) -> Option<&dyn error::Error> { - match *self { - Error::Normal(ref e) => error::Error::cause(e), - Error::Ssl(ref e, _) => error::Error::cause(e), - } - } - fn source(&self) -> Option<&(dyn error::Error + 'static)> { match *self { Error::Normal(ref e) => Some(e),