Skip to content

Commit

Permalink
implement Error for &(impl Error)
Browse files Browse the repository at this point in the history
  • Loading branch information
KodrAus committed Aug 5, 2020
1 parent 1d601d6 commit 39466bc
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions library/std/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,27 @@ impl<T: Error> Error for Box<T> {
}
}

#[stable(feature = "error_by_ref", since = "1.47.0")]
impl<'a, T: Error + ?Sized> Error for &'a T {
#[allow(deprecated, deprecated_in_future)]
fn description(&self) -> &str {
Error::description(&**self)
}

#[allow(deprecated)]
fn cause(&self) -> Option<&dyn Error> {
Error::cause(&**self)
}

fn source(&self) -> Option<&(dyn Error + 'static)> {
Error::source(&**self)
}

fn backtrace(&self) -> Option<&Backtrace> {
Error::backtrace(&**self)
}
}

#[stable(feature = "fmt_error", since = "1.11.0")]
impl Error for fmt::Error {
#[allow(deprecated)]
Expand Down

0 comments on commit 39466bc

Please sign in to comment.