Skip to content

Commit

Permalink
Add impl Error for Arc
Browse files Browse the repository at this point in the history
  • Loading branch information
derekdreery committed Feb 22, 2021
1 parent 8a9f786 commit 0d6640a
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions library/std/src/error.rs
Expand Up @@ -30,6 +30,7 @@ use crate::mem::transmute;
use crate::num;
use crate::str;
use crate::string;
use crate::sync::Arc;

/// `Error` is a trait representing the basic expectations for error values,
/// i.e., values of type `E` in [`Result<T, E>`]. Errors must describe
Expand Down Expand Up @@ -507,6 +508,27 @@ impl<'a, T: Error + ?Sized> Error for &'a T {
}
}

#[stable(feature = "arc_error", since = "1.52.0")]
impl<T: Error + ?Sized> Error for Arc<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 0d6640a

Please sign in to comment.