Build Status Latest Version

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

```rust use from_variants::FromVariants;

[derive(Debug, Clone, PartialEq, Eq, FromVariants)]

pub enum Lorem { Str(String), Num(u16), }

fn main() { assert_eq!(Lorem::Num(10), Lorem::from(10)); } ```

You can skip variants to avoid type collisions:

```rust use from_variants::FromVariants;

[derive(Debug, Clone, PartialEq, Eq, FromVariants)]

pub enum Ipsum { Hello(String),

#[from_variants(skip)]
Goodbye(String),

}

fn main() { asserteq!(Ipsum::Hello("John".tostring()), Ipsum::from("John".to_string())); } ```

Features