#enums #utils #string #proc-macro #generate

macro map-enum

This package introduces a procedural macro for generating typed enums

2 releases

0.1.1 Oct 21, 2024
0.1.0 Oct 21, 2024

#479 in Procedural macros

24 downloads per month

Apache-2.0

10KB
105 lines

Typed Enum

String Enum

use map_enum::*;

#[derive(Default)]
#[StringEnum]
pub enum HTTPVersion {
    Http0_9 = "HTTP/0.9",
    Http1_0 = "HTTP/1.0",
    #[default]
    Http1_1 = "HTTP/1.1",
    Http2 = "HTTP/2",
    Http3 = "HTTP/3",
}

Introduces new enum grammar under the #[StringEnum] macro, which implements string serialization and deserialization methods.


lib.rs:

This module contains the procedural macro implementation for the StringEnum attribute.

Dependencies

~220–660KB
~16K SLoC