use {core::convert::TryFrom, derive_try_from_primitive::TryFromPrimitive};
#[derive(TryFromPrimitive, Debug, PartialEq)]
#[repr(u16)]
enum Foo {
A, B = 100, C = 200, D, E, }
#[test]
fn generated_impl() {
let a = Foo::try_from(0);
let b = Foo::try_from(100);
let c = Foo::try_from(200);
let d = Foo::try_from(201);
let e = Foo::try_from(202);
let bad = Foo::try_from(300);
assert_eq!(a.unwrap(), Foo::A);
assert_eq!(b.unwrap(), Foo::B);
assert_eq!(c.unwrap(), Foo::C);
assert_eq!(d.unwrap(), Foo::D);
assert_eq!(e.unwrap(), Foo::E);
if let Err(value) = bad {
assert_eq!(value, 300, "Input is returned for convenience");
}
}