value-enum 1.0.0

Macro for generating enums associated with values
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented2 out of 2 items with examples
  • Size
  • Source code size: 5.91 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.05 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • mira-neko/value-enum
    5 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • mira-neko

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)
);