Skip to content

Conversation

@soareschen
Copy link
Collaborator

@soareschen soareschen commented Oct 17, 2025

Summary

With #175 deprecating #[cgp_context], we need a different way for concrete contexts to inherit from a preset. This PR introduces a new #[cgp_inherit] macro that can be used for a context to inherit from a preset.

Example

Given the following:

#[cgp_inherit(MyPreset)]
pub struct App { ... }

The following will be generated:

impl<Name> DelegateComponent<Name> for App
where
    Self: MyPreset::IsPreset<Name>,
    MyPreset::Components: DelegateComponent<Name>,
{
    type Delegate = <MyPreset::Components as DelegateComponent<Name>>::Delegate;
}
impl<Name, Context, Params> IsProviderFor<Name, Context, Params>
    for App
where
    Self: MyPreset::IsPreset<Name>,
    MyPreset::Components: IsProviderFor<Name, Context, Params>,
{
}

Note that even with the blanket implementation of DelegateComponent, we can still implement consumer traits for App if the given component key is not found in the preset.

@soareschen soareschen merged commit 3b8befa into main Oct 17, 2025
5 checks passed
@soareschen soareschen deleted the cgp-inherit branch October 17, 2025 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants