Newtype Variant Conversions
Rust macro crate to automatically generate conversions from variant types into the target enum.
This crate requires Rust 1.15 or above to compile on stable.
Examples
extern crate from_variants;
You can skip variants to avoid type collisions:
extern crate from_variants;
Features
- Variant opt-out: To skip a variant, add
#[from_variants(skip)]
to that variant. - Conversion support: Use
#[from_variants(into)]
at the enum or variant level to get a generated conversion that acceptsInto<VariantType>
. In practice, this will only work with types defined in the same crate; otherwise you'll get conflicting impl errors. - no_std support: Generated conversions do not depend on the standard library.