Purpose

This project is a proof of concept of implementing anonymous enum in Rust via proc-macro.

If you are seeking for error handling, perhaps cex crate is more suitable for you.

Naming

Anonymous enums composed of x variants are named as Enum1, Enum2, ... etc.

Variants are named as _0, _1, ... etc.

type converting rules:

  1. Each variant type in an EnumX is convertable to this EnumX.

  2. An EnumX T is convertable to another EnumX U if all variants in T are in U.

Inside a function with #[enumx] attribute and returning EnumX, the code can return any type that is convertable to the function return type.

However, explicit .into() are required.

Examples

Limitation

License

Licensed under MIT.