Skip to content

Commit 39466bc

Browse files
committedAug 5, 2020
implement Error for &(impl Error)
1 parent 1d601d6 commit 39466bc

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
 

‎library/std/src/error.rs

+21
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,27 @@ impl<T: Error> Error for Box<T> {
506506
}
507507
}
508508

509+
#[stable(feature = "error_by_ref", since = "1.47.0")]
510+
impl<'a, T: Error + ?Sized> Error for &'a T {
511+
#[allow(deprecated, deprecated_in_future)]
512+
fn description(&self) -> &str {
513+
Error::description(&**self)
514+
}
515+
516+
#[allow(deprecated)]
517+
fn cause(&self) -> Option<&dyn Error> {
518+
Error::cause(&**self)
519+
}
520+
521+
fn source(&self) -> Option<&(dyn Error + 'static)> {
522+
Error::source(&**self)
523+
}
524+
525+
fn backtrace(&self) -> Option<&Backtrace> {
526+
Error::backtrace(&**self)
527+
}
528+
}
529+
509530
#[stable(feature = "fmt_error", since = "1.11.0")]
510531
impl Error for fmt::Error {
511532
#[allow(deprecated)]

0 commit comments

Comments
 (0)
Please sign in to comment.