Skip to content

Instantly share code, notes, and snippets.

macro_rules! wrapped_enum {
($(#[$attr:meta])* pub enum $enum_name:ident, $($enum_variant_name:ident($ty:ty),)+) => (
$(#[$attr])*
pub enum $enum_name { $($enum_variant_name($ty)),+ }
$(impl From<$ty> for $enum_name {
fn from (ty: $ty) -> Self {
$enum_name::$enum_variant_name(ty)
}
})+
);