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
/**
This is the core trait used by the `delegate_component!` macro to define a mapping
from `Name` to `Delegate` on the target `Self` type.
## `DelegateComponent` as a type-level key-value map
Essentially, `DelegateComponent` turns the `Self` type into a type-level key-value map,
with `Name` as the key and `Delegate` as the value. The implementation of
`DelegateComponent` serves as "setting" an entry of `Self` at `Name` to `Delegate`.
Then, the inclusion of `DelegateComponent` in a constraint serves as "getting" the
`Delegate` value with the provided `Name` as the key.
When `Name` type in `DelegateComponent` is a CGP component name type, then the `Self`
type would also automatically implement the corresponding provider trait through the
blanket implementation.
However, it is also common to use `DelegateComponent` with regular types as the `Name`
key, especially when it is used to define lookup tables for providers such as
`UseDelegate`. In such cases, the `Self` type that implements `DelegateComponent` would
not be used to implement any provider trait.
## Examples
As an example, given the following `delegate_component!` macro invocation:
```rust,ignore
delegate_component! {
MyComponent {
GreeterComponent: GreetHello,
}
}
```
would generate the following impl:
```rust,ignore
impl DelegateComponent<GreeterComponent> for MyComponent {
type Delegate = GreetHello;
}
```
*/