Implement `std::fmt::Debug` for `ecs::observer::Trigger`
Objective
I tried writing something like this in my project
.observe(|e: Trigger<OnAdd, Skeleton>| {
panic!("Skeletoned! {e:?}");
});
and it didn't compile.
Having Debug trait defined on Trigger event will ease debugging the observers a little bit.
Solution
Add a bespoke Debug implementation when both the bundle and the event have Debug implemented for them.
Testing
I've added println!("{trigger:#?}"); to the observers example
and it compiled!
Caveats with this PR are:
- removing this implementation if for any reason we will need it, will be a breaking change
- the implementation is manually generated, which adds potential toil when changing the
Triggerstructure
Showcase
Log output:
on_add_mine: Trigger {
event: OnAdd,
propagate: false,
trigger: ObserverTrigger {
observer: 2v1#4294967298,
event_type: ComponentId(
0,
),
entity: 454v1#4294967750,
},
_marker: PhantomData<observers::Mine>,
}
Thank you for maintaining this engine! :orange_heart:
Welcome, new contributor!
Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨
Looks like we added (almost) the same labels at the same time 😅 @MrGVSV
I can fix the doctest some time tomorrow
Doctests for bevy_ecs are run separately, bevy_ecs doesn't depend on bevy, meaning it doesn't have access to the DefaultPlugins.
I tried to use the minimal startup_system example, but bevy_ecs doesn't have access to bevy_app either.
I think the doctest in its current form does not provide value, as it is impossible to make it compile while still looking as regular bevy code. I'll remove it