feat: implement proc macros for domain trait delegation#43
Open
arjo129 wants to merge 4 commits into
Open
Conversation
This commit introduces the mapf-derive crate which provides the #[derive(Domain)] macro. This macro allows for a more ergonomic and readable way to define domains by aggregating core traits (Activity, Weighted, Informed, etc.) through struct field delegation. Examples have been added to demonstrate usage with basic traits and the AStar planner. Assisted-by: Gemini CLI Signed-off-by: Arjo Chakravarty <arjoc@intrinsic.ai>
mxgrey
reviewed
Jun 17, 2026
Comment on lines
+38
to
+42
| #[weighted] | ||
| cost: ConstantCost, | ||
|
|
||
| #[informed] | ||
| heuristic: ManhattanHeuristic, |
Contributor
There was a problem hiding this comment.
I know that these attribute names are just reflecting the trait names that they represent, but it feels a bit stilted to me. Would it be too confusing if we used attributes names like #[weight] and #[heuristic] to map to the appropriate traits? I'd be open to renaming the traits to correspond (e.g. Weight and Heuristic).
| /// Define a domain using the new derive macro. | ||
| /// Adding Clone to GridDomain because AStar<D> needs to be Clone for the planner. | ||
| #[derive(Domain, Clone)] | ||
| #[domain(state = Point, error = NoError)] |
Contributor
There was a problem hiding this comment.
What would you think of also adding action = _ here? We would tweak the Activity trait like
pub trait Activity<State, Action> {
}
and we would remove the type Action associated type from Activity.
Comment on lines
+43
to
+45
| pub use super::algorithm::{self, *}; | ||
|
|
||
| pub use super::domain::{self, *}; |
Contributor
There was a problem hiding this comment.
I can't think of why we need the algorithm and domain module names inside the prelude.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New feature implementation
Implemented feature
Proc macros for domain trait delegation
Implementation description
This commit introduces the mapf-derive crate which provides the #[derive(Domain)] macro. This macro allows for a more ergonomic and readable way to define domains by aggregating core traits (Activity, Weighted, Informed, etc.) through struct field delegation.
Examples have been added to demonstrate usage with basic traits and the AStar planner.
GenAI Use
We follow OSRA's policy on GenAI tools
Generated-by: Gemini CLI