#enums #nutype #nutype-enum

nutype-enum

Helper macro to create a nutype that behaves like an enum

6 releases

Uses new Rust 2024

new 0.1.5 May 17, 2025
0.1.4 May 15, 2025
0.1.3 Apr 27, 2025
0.1.2 Feb 21, 2025
0.0.1 Feb 9, 2025

#363 in Video

Download history 276/week @ 2025-02-09 256/week @ 2025-02-16 29/week @ 2025-02-23 15/week @ 2025-03-02 4/week @ 2025-03-09 4/week @ 2025-04-06 3/week @ 2025-04-13 158/week @ 2025-04-27 21/week @ 2025-05-04 197/week @ 2025-05-11

376 downloads per month
Used in 7 crates (5 directly)

MIT/Apache

13KB
101 lines

nutype-enum

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

License: MIT OR Apache-2.0 docs.rs crates.io GitHub Actions: ci Codecov


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

See the changelog for a full release history.

Feature flags

  • docs — Enables changelog and documentation of feature flags

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

use nutype_enum::nutype_enum;

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

~0–660KB
~12K SLoC