1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
macro_rules! enum_from { ( $ty:ty { $($from_ty:ty => $variant:ident),+$(,)? } ) => { $( impl From<$from_ty> for $ty { fn from(value: $from_ty) -> $ty { Self::$variant(value) } } )+ }; }