Enumorph
Derive macro to generate TryFrom
and From
implementations for converting between newtype enum variants and their wrapped values.
;
;
// Enum::A(A("a"))
from;
// Ok(A("a"))
try_from;
// Enum::B { b: B(1) }
from;
// Ok(B(1))
try_from
Limitations
If two variants "wrap" the same type, then the resulting From and TryFrom implementations will overlap. In this case, you can wrap the inner type in a newtype:
;
;