value-enum

Crates.iovalue-enum
lib.rsvalue-enum
version1.0.0
sourcesrc
created_at2022-08-26 09:16:06.316622
updated_at2023-07-31 18:45:10.423612
descriptionMacro for generating enums associated with values
homepage
repositoryhttps://github.com/mira-neko/value-enum
max_upload_size
id652671
size6,226
Mira Nekomimi-Sireneva (mira-neko)

documentation

README

value-enum docs.rs GitHub code size in bytes Crates.io Crates.io

Macro for generating enums associated with values.

Example

use value_enum::value_enum;

value_enum!(
  #[derive(Clone, Copy, PartialEq, Eq, Debug)]
  enum Abc: char {
    A = 'a',
    B = 'b',
    C = 'c',
  }
);

assert_eq!(
  char::from(Abc::A),
  'a'
);

assert_eq!(
  Abc::try_from('b'),
  Ok(Abc::B)
);
Commit count: 16

cargo fmt