inkpad_support/derive/mod.rs
1//! macros
2/// Error generator
3#[macro_export]
4macro_rules! errors {
5 ($($e:ident),*) => {
6 #[derive(Debug)]
7 #[allow(missing_docs)]
8 pub enum Error {
9 $($e(String),)+
10 }
11
12 impl Display for Error {
13 fn fmt(&self, f: &mut Formatter<'_>) -> FmtResult {
14 match self {
15 $(Error::$e(e) => e.fmt(f),)+
16 }
17 }
18 }
19
20 impl ErrorTrait for Error {}
21
22 $(
23 impl From<$e> for Error {
24 fn from(e: $e) -> Error {
25 Error::$e(format!("{:?}", e))
26 }
27 }
28 )+
29 };
30}