1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/**
The `Either` type is used to represent an _anonymous sum type_.
Similar to [`Cons`](crate::types::Cons), `Either` is used to form a sum type
by combining a chain of `Either` types, and terminated with a [`Void`] type.
But unlike product types, a sum type has values that belong to one
of the variants in the list.
`Either` is most often used through the `Sum!` macro, which accepts a list of
types and turns them into a chain of `Either` types.
## Example
Given the following sum type definition:
```rust,ignore
type MyUnion = Sum![u32, String, bool];
```
The following type would be generated:
```rust,ignore
type MyUnion = Either<u32, Either<String, Either<bool, Void>>>;
```
*/
/**
The `Void` type is used to represent the end of an _anonymous sum type_,
or an _empty_ sum type.
`Void` is commonly used as the `Tail` of a [`Either`] type, to terminate the list.
When used on its own, it represents an empty sum type, which can _never be constructed_.
`Void` is functionally the same as the
[_never_ type](https://doc.rust-lang.org/std/primitive.never.html), `!`,
or otherwise
[`Infallible`](https://doc.rust-lang.org/std/convert/enum.Infallible.html).
However, we define a separate `Void` type, to make it more clear that it is
specifically used for terminating a sum type.
Read more about sum types in [`Either`].
*/