12 releases

0.4.3 Apr 4, 2021
0.4.2 Feb 18, 2021
0.4.1 Nov 2, 2020
0.3.1 Jun 28, 2020
0.1.0 Nov 21, 2018

#1070 in Rust patterns

Download history 10/week @ 2024-08-19 9/week @ 2024-08-26 9/week @ 2024-09-02 16/week @ 2024-09-09 10/week @ 2024-09-16 54/week @ 2024-09-23 18/week @ 2024-09-30 8/week @ 2024-10-07 21/week @ 2024-10-14 20/week @ 2024-10-21 18/week @ 2024-10-28 20/week @ 2024-11-04 13/week @ 2024-11-11 16/week @ 2024-11-18 26/week @ 2024-11-25 21/week @ 2024-12-02

77 downloads per month
Used in 5 crates (3 directly)

MIT license

42KB
789 lines

Motivation

Simulating ad-hoc enums which

  1. can be converted between enums that share a common set of variant types.

  2. can implement traits that haven been implemented by all variants.

Usage

Add this crate to Cargo.toml

Cargo.toml:

enumx = "0.4"

Add this if you want to support up to 32 variants:

features = ["enum32"]

src/lib.rs:

use enumx::export::*;

If you want to use predefined enum types:

use enumx::predefined::*;

Features

  • "union types" simulation, aka "enum exchange".

  • summaries into an enum, the returned values of different types by functions that returns impl Trait.

  • macros to help implementing traits for enums the variants of which have all implemented the traits.

Documentation

See the enumx book for more.

License

Licensed under MIT.


lib.rs:

enumx = ENUM eXtensions.

See the enumx book for more.

Dependencies

~2.5MB
~54K SLoC