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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
use Debug;
use PhantomData;
/**
The `Field` type, a.k.a. `ω`, is used to represent a _named_ field entry
within a product type or a sum type.
`Field` is parameterized by a phantom `Tag` type, which is used to represent
the field name as type. Typically, this would either be a type-level string
such as `Symbol!("name")`, or a type-level index such as `Index<0>`.
Aside from that, `Field` is essentially a wrapper around `Value`.
`Field` is mainly used within the derived [`HasFields`](crate::traits::HasFields)
implementations, to include the field name in the generic product or sum
representation of the given struct or enum.
`Field` is also shown as `ω` to improve the readability of compiler error
messages. It is mainly useful when the type from `HasFields::Fields` is shown,
which would contain a lot of `Field`s and tend to take up a lot of screen space
to read.
## Example
Given the following struct definition:
```rust,ignore
#[derive(HasFields)]
pub struct MyContext {
pub name: String,
pub age: u8,
}
```
The following `HasFields` implementation would be generated:
```rust,ignore
impl HasFields for MyContext {
type Fields = Product![Field<Symbol!("name"), String>, Field<Symbol!("age"), u8>];
}
```
which would be shown with the shortened representation as:
```rust,ignore
impl HasFields for MyContext {
type Fields =
π<ω<Symbol!("name"), String>,
π<ω<Symbol!("age"), u8>,
ε>>;
}
```
*/
pub use ω as Field;