4 releases

0.1.3 Jun 10, 2024
0.1.2 Sep 30, 2023
0.1.1 Sep 28, 2023
0.1.0 Sep 28, 2023

#399 in Procedural macros

Download history 163/week @ 2024-11-21 104/week @ 2024-11-28 198/week @ 2024-12-05 148/week @ 2024-12-12 49/week @ 2024-12-19 25/week @ 2024-12-26 117/week @ 2025-01-02 223/week @ 2025-01-09 103/week @ 2025-01-16 161/week @ 2025-01-23 162/week @ 2025-01-30 135/week @ 2025-02-06 81/week @ 2025-02-13 84/week @ 2025-02-20 74/week @ 2025-02-27 77/week @ 2025-03-06

320 downloads per month
Used in 2 crates

MIT/Apache

8KB

Overview

This crate provides simple proc macros for naming enum variants.

#[derive(SimpleSnakeNames)]
enum Animal {
    HoneyBee,
    GreatWhiteShark(usize),
    PoisonDartFrog { spotted: bool },
}

// expands to
impl Animal {
    fn name(&self) -> &'static str {
        match self {
            HoneyBee => "honey_bee",
            GreatWhiteShark(..) => "great_white_shark",
            PoisonDartFrog { .. } => "poison_dart_frog",
        }
    }
}

License

© 2022-2023 Offchain Labs, Inc.

This project is licensed under either of

at your option.

The SPDX license identifier for this project is MIT OR Apache-2.0.

Dependencies

~0.6–1MB
~21K SLoC