1use std::error::Error;
2use std::panic::UnwindSafe;
3
4#[doc(hidden)]
5pub trait AsDynError<'a>: Sealed {
6 fn as_dyn_error(&self) -> &(dyn Error + 'a);
7}
8
9impl<'a, T: Error + 'a> AsDynError<'a> for T {
10 #[inline]
11 fn as_dyn_error(&self) -> &(dyn Error + 'a) {
12 self
13 }
14}
15
16impl<'a> AsDynError<'a> for dyn Error + 'a {
17 #[inline]
18 fn as_dyn_error(&self) -> &(dyn Error + 'a) {
19 self
20 }
21}
22
23impl<'a> AsDynError<'a> for dyn Error + Send + 'a {
24 #[inline]
25 fn as_dyn_error(&self) -> &(dyn Error + 'a) {
26 self
27 }
28}
29
30impl<'a> AsDynError<'a> for dyn Error + Send + Sync + 'a {
31 #[inline]
32 fn as_dyn_error(&self) -> &(dyn Error + 'a) {
33 self
34 }
35}
36
37impl<'a> AsDynError<'a> for dyn Error + Send + Sync + UnwindSafe + 'a {
38 #[inline]
39 fn as_dyn_error(&self) -> &(dyn Error + 'a) {
40 self
41 }
42}
43
44#[doc(hidden)]
45pub trait Sealed {}
46impl<'a, T: Error + 'a> Sealed for T {}
47impl<'a> Sealed for dyn Error + 'a {}
48impl<'a> Sealed for dyn Error + Send + 'a {}
49impl<'a> Sealed for dyn Error + Send + Sync + 'a {}
50impl<'a> Sealed for dyn Error + Send + Sync + UnwindSafe + 'a {}
51