Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve derive(Event) and simplify macro code #18083

Open
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

Bleachfuel
Copy link
Contributor

@Bleachfuel Bleachfuel commented Feb 27, 2025

Objective

simplify some code and improve Event macro

Showcase

you can now write derive Events like so

#[derive(event)]
#[event(auto_propagate, traversal = MyType)]
struct MyEvent;

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events S-Needs-Review Needs reviewer attention (from anyone!) to move forward D-Macros Code that generates Rust code C-Code-Quality A section of code that is hard to understand or change labels Feb 28, 2025
@Bleachfuel
Copy link
Contributor Author

Test that is failing to compile passes on my machine, but on CI it has a weird error :(

@Bleachfuel
Copy link
Contributor Author

Ready for review!

@Bleachfuel Bleachfuel changed the title simplify macro code in Component.rs Improve derive(Event) andsimplify macro code. Mar 1, 2025
@Bleachfuel Bleachfuel changed the title Improve derive(Event) andsimplify macro code. Improve derive(Event) and simplify macro code Mar 1, 2025
@bevyengine bevyengine deleted a comment from github-actions bot Mar 3, 2025
@Bleachfuel
Copy link
Contributor Author

Bleachfuel commented Mar 4, 2025

According to Dtolnay: dtolnay/syn#1850, this is not desired behaviour.

#[relationship(relationship_target = Attachments<T>)]

Instead it should be

#[relationship(relationship_target = Attachments::<T>)]

I could make it this way to make the relationship parsing nicer, but it makes it harder to understand the error for users as the error is add <T> and not add ::<T>.

@alice-i-cecile alice-i-cecile added the C-Usability A targeted quality-of-life change that makes Bevy easier to use label Mar 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Macros Code that generates Rust code S-Needs-Review Needs reviewer attention (from anyone!) to move forward
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants