#enums #nutype

nutype-enum

Helper macro to create a nutype that behaves like an enum

3 releases

0.1.2 Feb 21, 2025
0.1.1 Feb 17, 2025
0.1.0 Feb 10, 2025
0.0.1 Feb 9, 2025

#656 in Rust patterns

Download history 233/week @ 2025-02-05 162/week @ 2025-02-12 158/week @ 2025-02-19 19/week @ 2025-02-26

572 downloads per month
Used in 3 crates (2 directly)

MIT/Apache

7KB
88 lines

nutype-enum

[!WARNING]
This crate is under active development and may not be stable.

crates.io docs.rs


The crate provides a macro to create a new enum type with a single field.

Why do we need this?

This is useful when you have a value and you want to have enum like behavior and have a catch all case for all other values.

Examples

nutype_enum! {
    pub enum AacPacketType(u8) {
        SeqHdr = 0x0,
        Raw = 0x1,
    }
}

License

This project is licensed under the MIT or Apache-2.0 license. You can choose between one of them if you use this work.

SPDX-License-Identifier: MIT OR Apache-2.0

Dependencies