bevy/crates/bevy_ecs/src
Sorseg f9d7a2ca02
Implement std::fmt::Debug for ecs::observer::Trigger (#14857)
# Objective
I tried writing something like this in my project
```rust
.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](938d810766/examples/ecs/observers.rs (L124))
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 `Trigger` structure

## Showcase

Log output:
```rust
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! 🧡
2024-08-25 16:55:54 +00:00
..
entity Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
event Minimal Bubbling Observers (#13991) 2024-07-15 13:39:41 +00:00
identifier
observer Implement std::fmt::Debug for ecs::observer::Trigger (#14857) 2024-08-25 16:55:54 +00:00
query Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
reflect Use map_unchanged in reflection instead of creating a Mut manually. (#14692) 2024-08-15 14:26:57 +00:00
schedule Use #[doc(fake_variadic)] to improve docs readability (#14703) 2024-08-12 18:54:33 +00:00
storage Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
system SystemParamBuilder - Support dynamic system parameters (#14817) 2024-08-25 14:23:44 +00:00
world Implement std::fmt::Debug for ecs::observer::Trigger (#14857) 2024-08-25 16:55:54 +00:00
archetype.rs feat: add insert_if_new (#14397) (#14646) 2024-08-15 20:31:41 +00:00
batching.rs
bundle.rs Apply unused_qualifications lint (#14828) 2024-08-21 12:29:33 +00:00
change_detection.rs Add filter_map_unchanged to Mut<T> (#14837) 2024-08-22 17:51:21 +00:00
component.rs Component Lifecycle Hook & Observer Trigger for replaced values (#14212) 2024-07-15 15:24:15 +00:00
intern.rs
label.rs Add mappings to EntityMapper (#13727) 2024-06-08 12:52:23 +00:00
lib.rs Add Command and co. to prelude (#14751) 2024-08-15 13:33:32 +00:00
removal_detection.rs Created an EventMutator for when you want to mutate an event before reading (#13818) 2024-07-08 14:53:06 +00:00
traversal.rs Minimal Bubbling Observers (#13991) 2024-07-15 13:39:41 +00:00