Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/xieyuschen/rs-sumtype-boilerplate

[WIP] Macros for manipulating enums in Rust
https://github.com/xieyuschen/rs-sumtype-boilerplate

Last synced: about 1 month ago
JSON representation

[WIP] Macros for manipulating enums in Rust

Awesome Lists containing this project

README

        

# rs-sumtype-boilplate

Library `rs-sumtype-boilplate` provides some useful macros to manipulate sum-type(enum) inside your project.

## Supported Macros

### Macro `create_sumtype`

Macro `create_sumtype` generates an enum type according to the types you passed.
For example, the following macro usage will produce an enum `MySum`.

```rust
struct A;
struct B;
create_sumtype!(MySum, A, B);
```

The `MySum` is equivalent to the definition below:

```rust
enum MySum {
MySumA(A),
MySumB(B),
}
```