t_rust_less_lib/macros.rs
1macro_rules! error_convert_from {
2 ($from_type:ty, $to_type:ident, $tgt:ident (display)) => {
3 impl From<$from_type> for $to_type {
4 fn from(error: $from_type) -> Self {
5 $to_type::$tgt(format!("{}", error))
6 }
7 }
8 };
9 ($from_type:ty, $to_type:ident, $tgt:ident (direct)) => {
10 impl From<$from_type> for $to_type {
11 fn from(error: $from_type) -> Self {
12 $to_type::$tgt(error)
13 }
14 }
15 };
16}