3 releases

0.1.2 Sep 30, 2023
0.1.1 Sep 28, 2023
0.1.0 Sep 28, 2023

#1769 in Procedural macros

Download history 14/week @ 2023-12-18 20/week @ 2024-01-08 6/week @ 2024-01-15 72/week @ 2024-01-22 44/week @ 2024-01-29 6/week @ 2024-02-05 73/week @ 2024-02-12 36/week @ 2024-02-19 66/week @ 2024-02-26 72/week @ 2024-03-04 147/week @ 2024-03-11 9/week @ 2024-03-18 17/week @ 2024-03-25 72/week @ 2024-04-01

257 downloads per month
Used in cargo-stylus

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

~1–1.4MB
~28K SLoC