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

#2428 in Procedural macros

Download history 413/week @ 2025-09-01 169/week @ 2025-09-08 66/week @ 2025-09-15 85/week @ 2025-09-22 98/week @ 2025-09-29 727/week @ 2025-10-06 2367/week @ 2025-10-13 2761/week @ 2025-10-20 159/week @ 2025-10-27 843/week @ 2025-11-03 185/week @ 2025-11-10 443/week @ 2025-11-17 197/week @ 2025-11-24 66/week @ 2025-12-01 229/week @ 2025-12-08 26/week @ 2025-12-15

532 downloads per month
Used in 4 crates (3 directly)

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.5–1MB
~18K SLoC