#macro-derive #enums #derive-enums

macro no-std variants-derive

derive macros enabling the variants crate

2 releases

Uses new Rust 2024

0.0.1 Aug 26, 2025
0.0.0 Dec 2, 2024

#65 in #derive-enums

Download history 76/week @ 2025-12-04 45/week @ 2025-12-11 103/week @ 2025-12-18 141/week @ 2025-12-25 179/week @ 2026-01-01 121/week @ 2026-01-08 77/week @ 2026-01-15 83/week @ 2026-01-22 124/week @ 2026-01-29 73/week @ 2026-02-05 43/week @ 2026-02-12 126/week @ 2026-02-19 69/week @ 2026-02-26 75/week @ 2026-03-05 97/week @ 2026-03-12 76/week @ 2026-03-19

337 downloads per month
Used in 30 crates (via variants)

Apache-2.0

15KB
235 lines

variants

license crates.io docs.rs


The variants crates provides a suite of abstractions, utilities, and prodedural macros to facilitate the creation and management of enums and their variants in Rust.

Features

  • VariantConstructor - A derive macro for generating functional constructors for enum variants

Getting Started

Building from the source

Start by cloning the repository

git clone https://github.com/FL03/variants.git
cd variants

Building the project

cargo build --all-features -r -v --workspace

Running tests

cargo test --all-features -r -v --workspace

Usage

Add this to your Cargo.toml:

[dependencies.variants]
features = []
version = "0.1.0"

Examples

Basic Usage

    extern crate variants;

    fn main() -> Result<(), Box<dyn std::error::Error>> {
        tracing_subscriber::fmt::init();
        tracing::info!("Welcome to {name}", name = variants);


        Ok(())
    }

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

Dependencies

~110–475KB
~11K SLoC