enum_primitive::enum_from_primitive_impl_ty! [-] [+] [src]

macro_rules! enum_from_primitive_impl_ty {
    ($meth:ident, $ty:ty, $name:ident, $( $variant:ident )*) => {
        #[allow(non_upper_case_globals, unused)]
        fn $meth(n: $ty) -> $crate::Option<Self> {
            $( if n == $name::$variant as $ty {
                $crate::Option::Some($name::$variant)
            } else )* {
                $crate::Option::None
            }
        }
    };
}

Helper macro for internal use by enum_from_primitive!.