Hi all,
I'm creating a derive macro for implementing the FromStr
and TryFrom
traits for my enums. But I'd like to only create TryFrom<u8>
or TryFrom<u16>
depending on the memory size of the enum, tagged with #[repr(u8)]
or #[repr(u16)]
.
I can get the ident of the enum and can create both TryFrom<u8>
and TryFrom<u16>
traits, but I'd like to create them depending on the enum's size.
Any easy solution other than diving into the DeriveInput
structure and getting back the value inside the #[repr]
?
Enum example:
#[repr(u8)]
enum Foo {
A=1,
B=2
}
Thanks for your help.