Summary
At the moment, the mechanism for bulk delegation of preset components is still sub-optimal. To scale the use of CGP, we need to make it much easier to define component presets and combine multiple component presets.
New Syntax
The new preset macro would roughly have the following shape:
#[cgp_preset]
pub mod foo_preset {
#[extend]
use bar_crate::bar_preset;
#[extend {
exclude: [ BazTwoComponent ]
}]
use baz_crate::baz_preset;
pub struct Components {
FooOneComponent: FooOneImpl,
FooTwoComponent: FooTwoImpl,
}
}
Which would roughly expands to the following:
pub mod foo_preset {
pub trait IsMember {}
pub struct Components;
bar_crate::bar_preset::with_components! {
Name => {
impl DelegateComponent<Name> for Components {
type Delegate = bar_crate::bar_preset::Components;
}
impl IsMember for Name {}
}
}
baz_crate::baz_preset::with_components! {
exclude: [ BazTwoComponent ],
Name => {
impl DelegateComponent<Name> for Components {
type Delegate = baz_crate::baz_preset::Components;
}
impl IsMember for Name {}
}
}
impl DelegateComponent<FooOneComponent> for Components {
type Delegate = FooOneImpl;
}
impl IsMember for FooOneComponent {}
impl DelegateComponent<FooTwoComponent> for Components {
type Delegate = FooTwoImpl;
}
impl IsMember for FooTwoComponent {}
macro_rules with_components {
( $( $rest:tt )* ) => {
cgp::prelude::for_each! {
[ FooOneComponent, FooTwoComponent ],
$( $rest )*
}
bar_crate::bar_preset::with_components! {
$( $rest )*
}
baz_crate::baz_preset::with_components! {
$( $rest )*
}
}
}
}
Summary
At the moment, the mechanism for bulk delegation of preset components is still sub-optimal. To scale the use of CGP, we need to make it much easier to define component presets and combine multiple component presets.
New Syntax
The new preset macro would roughly have the following shape:
Which would roughly expands to the following: