/rust/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.95/src/wrapper.rs
Line | Count | Source (jump to first uncovered line) |
1 | | use crate::StdError; |
2 | | use core::fmt::{self, Debug, Display}; |
3 | | |
4 | | #[cfg(any(feature = "std", not(anyhow_no_core_error)))] |
5 | | use alloc::boxed::Box; |
6 | | |
7 | | #[cfg(error_generic_member_access)] |
8 | | use core::error::Request; |
9 | | |
10 | | #[repr(transparent)] |
11 | | pub struct MessageError<M>(pub M); |
12 | | |
13 | | impl<M> Debug for MessageError<M> |
14 | | where |
15 | | M: Display + Debug, |
16 | | { |
17 | 0 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
18 | 0 | Debug::fmt(&self.0, f) |
19 | 0 | } Unexecuted instantiation: <anyhow::wrapper::MessageError<alloc::string::String> as core::fmt::Debug>::fmt Unexecuted instantiation: <anyhow::wrapper::MessageError<&str> as core::fmt::Debug>::fmt |
20 | | } |
21 | | |
22 | | impl<M> Display for MessageError<M> |
23 | | where |
24 | | M: Display + Debug, |
25 | | { |
26 | 0 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
27 | 0 | Display::fmt(&self.0, f) |
28 | 0 | } Unexecuted instantiation: <anyhow::wrapper::MessageError<alloc::string::String> as core::fmt::Display>::fmt Unexecuted instantiation: <anyhow::wrapper::MessageError<&str> as core::fmt::Display>::fmt |
29 | | } |
30 | | |
31 | | impl<M> StdError for MessageError<M> where M: Display + Debug + 'static {} |
32 | | |
33 | | #[repr(transparent)] |
34 | | pub struct DisplayError<M>(pub M); |
35 | | |
36 | | impl<M> Debug for DisplayError<M> |
37 | | where |
38 | | M: Display, |
39 | | { |
40 | 0 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
41 | 0 | Display::fmt(&self.0, f) |
42 | 0 | } |
43 | | } |
44 | | |
45 | | impl<M> Display for DisplayError<M> |
46 | | where |
47 | | M: Display, |
48 | | { |
49 | 0 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
50 | 0 | Display::fmt(&self.0, f) |
51 | 0 | } |
52 | | } |
53 | | |
54 | | impl<M> StdError for DisplayError<M> where M: Display + 'static {} |
55 | | |
56 | | #[cfg(any(feature = "std", not(anyhow_no_core_error)))] |
57 | | #[repr(transparent)] |
58 | | pub struct BoxedError(pub Box<dyn StdError + Send + Sync>); |
59 | | |
60 | | #[cfg(any(feature = "std", not(anyhow_no_core_error)))] |
61 | | impl Debug for BoxedError { |
62 | 0 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
63 | 0 | Debug::fmt(&self.0, f) |
64 | 0 | } |
65 | | } |
66 | | |
67 | | #[cfg(any(feature = "std", not(anyhow_no_core_error)))] |
68 | | impl Display for BoxedError { |
69 | 0 | fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { |
70 | 0 | Display::fmt(&self.0, f) |
71 | 0 | } |
72 | | } |
73 | | |
74 | | #[cfg(any(feature = "std", not(anyhow_no_core_error)))] |
75 | | impl StdError for BoxedError { |
76 | 0 | fn source(&self) -> Option<&(dyn StdError + 'static)> { |
77 | 0 | self.0.source() |
78 | 0 | } |
79 | | |
80 | | #[cfg(error_generic_member_access)] |
81 | 0 | fn provide<'a>(&'a self, request: &mut Request<'a>) { |
82 | 0 | self.0.provide(request); |
83 | 0 | } |
84 | | } |