mirror of
https://github.com/haraldh/chainerror.git
synced 2025-01-31 00:56:41 +01:00
more idiomatic
This commit is contained in:
parent
6ad9497512
commit
a869a2e3ea
18
src/lib.rs
18
src/lib.rs
|
@ -462,31 +462,19 @@ impl ChainErrorDown for dyn Error + 'static + Send + Sync {
|
|||
|
||||
impl<T: 'static + Display + Debug> Error for ChainError<T> {
|
||||
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<T: 'static + Display + Debug> Error for &ChainError<T> {
|
||||
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<T: 'static + Display + Debug> Error for &mut ChainError<T> {
|
||||
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())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue