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