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

#200 in Rust patterns

Download history 4/week @ 2021-07-03 2/week @ 2021-07-10 13/week @ 2021-07-17 4/week @ 2021-07-24 37/week @ 2021-07-31 3/week @ 2021-08-07 17/week @ 2021-08-14 5/week @ 2021-08-21 2/week @ 2021-09-04 1/week @ 2021-09-11 1/week @ 2021-09-18 12/week @ 2021-09-25 2/week @ 2021-10-02 16/week @ 2021-10-09 2/week @ 2021-10-16

78 downloads per month
Used in cex

MIT license

96KB
2K SLoC

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

~0.7–1.2MB
~27K SLoC