If you have an enum like:
#[repr(u8)]
enum Data {
Ok = 0x00,
Error = 0x01,
}
I think it would be handy to have it generate a TryFrom implementation. The error type could be set to (), it's easy to replace if need be.
Something like:
impl TryFrom<u8> for Data {
type Error = ();
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
0x00 => Ok(Self::Data),
0x01 => Ok(Self::Error),
_ => return Err(()),
}
}
}
If you have an enum like:
I think it would be handy to have it generate a
TryFromimplementation. The error type could be set to(), it's easy to replace if need be.Something like: