From a869a2e3ea33c39b2c31bfae2d781ac8635f359f Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Tue, 15 Jan 2019 09:17:58 +0100 Subject: [PATCH] more idiomatic --- src/lib.rs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 09df831..b052a53 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -462,31 +462,19 @@ impl ChainErrorDown for dyn Error + 'static + Send + Sync { impl Error for ChainError { fn source(&self) -> Option<&(dyn Error + 'static)> { - if let Some(ref e) = self.error_cause { - Some(e.as_ref()) - } else { - None - } + self.error_cause.as_ref().map(|e| e.as_ref()) } } impl Error for &ChainError { fn source(&self) -> Option<&(dyn Error + 'static)> { - if let Some(ref e) = self.error_cause { - Some(e.as_ref()) - } else { - None - } + self.error_cause.as_ref().map(|e| e.as_ref()) } } impl Error for &mut ChainError { fn source(&self) -> Option<&(dyn Error + 'static)> { - if let Some(ref e) = self.error_cause { - Some(e.as_ref()) - } else { - None - } + self.error_cause.as_ref().map(|e| e.as_ref()) } }