sneks

Crates.iosneks
lib.rssneks
version0.1.3
sourcesrc
created_at2023-09-28 22:17:30.342698
updated_at2024-06-10 21:55:11.582001
descriptionsimple macros for naming enum variants
homepagehttps://github.com/OffchainLabs/sneks
repositoryhttps://github.com/OffchainLabs/sneks
max_upload_size
id986747
size18,733
Rachel Bousfield (rachel-bousfield)

documentation

README

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.

Commit count: 6

cargo fmt