Sum

Macro Sum 

Source
Sum!() { /* proc-macro */ }
Expand description

The Sum! macro is used to define a sum type, with the given list of types as disjoint variants.

Given a list of types to the macro, it would generate a chain of Either types for each type in the list, and terminated with the Void type.

Read more about sum types in the documentation for Either.

§Example

Given the following sum type definition:

type MyUnion = Sum![u32, String, bool];

The following type would be generated:

type MyUnion = Either<u32, Either<String, Either<bool, Void>>>;

which would be shown with the shortened representation as:

type MyUnion = σ<u32, σ<String, σ<bool, θ>>>;