Newtype Variant Conversions
Rust macro crate to automatically generate conversions from variant types into the target enum.
This crate requires Rust 1.45 or above to compile on stable.
Examples
use FromVariants;
You can skip variants to avoid type collisions:
use FromVariants;
Features
- Variant opt-out: To skip a variant, add
#[from_variants(skip)]
to that variant. - Conversion opt-in: Use
#[from_variants(into)]
on an enum or variant to generate conversions that will automatically convert - for example, accepting a&str
for aString
variant. This must be used sparingly to avoid generating conflicting impls. - no_std support: Generated conversions do not depend on the standard library.