1macro_rules! enum_variant_from {
3 ($target: ident, $variant: ident, $source: ident) => {
4 impl From<$source> for $target {
5 fn from(inner: $source) -> Self {
6 $target::$variant(inner)
7 }
8 }
9 };
10}
11
12macro_rules! enum_variant_into_result {
14 ($source: ident, $variant: ident, $target: ident) => {
15 impl Into<Result<$target, $source>> for $source {
16 fn into(self) -> Result<$target, $source> {
17 match self {
18 $source::$variant(target) => Ok(target),
19 other => Err(other),
20 }
21 }
22 }
23 };
24}
25
26#[macro_export]
27macro_rules! include_json_as {
28 ($deserialize_as: ident, $file: expr) => {
29 serde_json::from_str::<$deserialize_as>(include_str!($file)).unwrap()
30 };
31}