Skip to content

Rename #[cgp_dispatch] to #[cgp_auto_dispatch]#155

Merged
soareschen merged 1 commit intomainfrom
cgp-auto-dispatch
Sep 13, 2025
Merged

Rename #[cgp_dispatch] to #[cgp_auto_dispatch]#155
soareschen merged 1 commit intomainfrom
cgp-auto-dispatch

Conversation

@soareschen
Copy link
Collaborator

@soareschen soareschen commented Sep 13, 2025

Summary

This PR renames the upcoming #[cgp_dispatch] macro to #[cgp_auto_dispatch].

This is to reserve the original name #[cgp_dispatch] so that it can be applied on CGP traits. On the other hand, #[cgp_auto_dispatch] is designed as a simplfied tool to work with regular enums, so that users don't need to adopt the full CGP to use it.

Example

#[cgp_auto_dispatch] will be used for cases like:

#[cgp_auto_dispatch]
pub trait HasArea {
    fn area(&self) -> f64;
}

On the other hand, in the future a new #[cgp_dispatch] will be implemented for CGP traits like:

#[cgp_dispatch]
#[cgp_component(AreaComputer)]
pub trait CanComputeArea<Shape> {
    fn compute_area(&self, shape: &Shape) -> f64;
}

where the dispatching is done on Shape instead of Self.

@soareschen soareschen merged commit 31166d0 into main Sep 13, 2025
5 checks passed
@soareschen soareschen deleted the cgp-auto-dispatch branch September 13, 2025 18:50
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