From 5a8108bd86faa6107e7a622e6297388fea3d6346 Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Sun, 12 Apr 2020 11:39:33 -0700 Subject: [PATCH] Implement `source` and not `cause` for FromSqlError --- src/types/from_sql.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/types/from_sql.rs b/src/types/from_sql.rs index 2e29492..b013e99 100644 --- a/src/types/from_sql.rs +++ b/src/types/from_sql.rs @@ -26,7 +26,7 @@ pub enum FromSqlError { InvalidUuidSize(usize), /// An error case available for implementors of the `FromSql` trait. - Other(Box), + Other(Box), } impl PartialEq for FromSqlError { @@ -75,12 +75,11 @@ impl Error for FromSqlError { } } - #[allow(clippy::match_same_arms)] - #[allow(deprecated)] - fn cause(&self) -> Option<&dyn Error> { - match *self { - FromSqlError::Other(ref err) => err.cause(), - _ => None, + fn source(&self) -> Option<&(dyn Error + 'static)> { + if let FromSqlError::Other(ref err) = self { + Some(&**err) + } else { + None } } }