#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

#356 in Procedural macros

Download history 154/week @ 2024-10-15 112/week @ 2024-10-22 6/week @ 2024-11-05

272 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

~225–670KB
~16K SLoC