| Crates.io | stupid-from-num |
| lib.rs | stupid-from-num |
| version | 0.1.0 |
| created_at | 2023-11-08 18:35:28.841961+00 |
| updated_at | 2023-11-08 18:35:28.841961+00 |
| description | Auto implement From trait on an enum. |
| homepage | https://github.com/tontinton/dbeel/stupid_from_num |
| repository | https://github.com/tontinton/dbeel/stupid_from_num |
| max_upload_size | |
| id | 1029250 |
| size | 4,199 |
A derive macro that adds a impl From<u8> to any enum.
If the number of items is bigger than u8::MAX, it will use u16, then u32 if bigger than u16::MAX.
Example:
use stupid_from_num::FromNum;
#[derive(FromNum)]
enum Example {
Zero,
One,
Two,
}
assert_eq!(Example::Zero.into(), 0);
assert_eq!(Example::One.into(), 1);
assert_eq!(Example::Two.into(), 2);