Example

```rust use core::convert::TryFrom; use derivetryfrom_primitive::TryFromPrimitive;

[derive(TryFromPrimitive)]

[repr(u16)]

enum Foo { Bar, Baz = 100, Quix = 200, }

// Generated Code: impl core::convert::TryFrom for Foo { type Error = u16;

fn try_from(n: 16) -> Result<Self, Self::Error> {
    match n {
        0 => Ok(Foo::Bar),
        100 => Ok(Foo::Baz),
        200 => Ok(Foo::Quix),
        _ => Err(n),
    }
}

}

fn main() { let bar = Foo::tryfrom(0); let baz = Foo::tryfrom(100); let quix = Foo::tryfrom(200); let bad = Foo::tryfrom(300); asserteq!(bar.unwrap() as u16, 0); asserteq!(baz.unwrap() as u16, 100); asserteq!(quix.unwrap() as u16, 200); if let Err(value) = bad { asserteq!(value, 300, "Input is returned for convenience"); } } ```