Skip to content

Add #[impl_generics] attribute to #[cgp_fn]#221

Merged
soareschen merged 1 commit intomainfrom
cgp-fn-impl-generics
Mar 26, 2026
Merged

Add #[impl_generics] attribute to #[cgp_fn]#221
soareschen merged 1 commit intomainfrom
cgp-fn-impl-generics

Conversation

@soareschen
Copy link
Copy Markdown
Collaborator

@soareschen soareschen commented Mar 26, 2026

This PR introduces a new #[impl_generics] attribute that can be used inside #[cgp_fn]. This allows the specified generic parameters to only be included in the generated impl, but not in the trait definition.

This allows the CGP function to bind generic fields using #[impl_generics] without polluting the trait with generic parameters.

For example:

#[cgp_fn]
#[impl_generics(Name: Display)]
pub fn greet(&self, #[implicit] name: &Name) -> String {
    format!("Hello, {}!", name)
}

#[cgp_fn]
#[uses(Greet)]
pub fn print_greet(&self) {
    println!("{}", self.greet());
}

@soareschen soareschen merged commit a087607 into main Mar 26, 2026
5 checks passed
@soareschen soareschen deleted the cgp-fn-impl-generics branch March 26, 2026 20:46
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.

1 participant