stupid-from-num

Crates.iostupid-from-num
lib.rsstupid-from-num
version0.1.0
sourcesrc
created_at2023-11-08 18:35:28.841961
updated_at2023-11-08 18:35:28.841961
descriptionAuto implement From trait on an enum.
homepagehttps://github.com/tontinton/dbeel/stupid_from_num
repositoryhttps://github.com/tontinton/dbeel/stupid_from_num
max_upload_size
id1029250
size4,199
Tony Solomonik (tontinton)

documentation

README

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);
Commit count: 454

cargo fmt