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

#310 in Procedural macros

Download history 157/week @ 2024-08-12 51/week @ 2024-08-19 185/week @ 2024-08-26 119/week @ 2024-09-02 121/week @ 2024-09-09 82/week @ 2024-09-16 76/week @ 2024-09-23 81/week @ 2024-09-30 73/week @ 2024-10-07 137/week @ 2024-10-14 170/week @ 2024-10-21 177/week @ 2024-10-28 166/week @ 2024-11-04 134/week @ 2024-11-11

675 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–1.1MB
~22K SLoC