You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This creates an issue when attempting to actually use these implementations (especially that of Hash), as it requires them to be implemented on the events themselves; despite the generic only being used in a marker type.
It would be better to manually implement these traits to ignore the marker, freeing them up to be used in more places than they are currently:
error[E0599]: the method `insert` exists forstruct `Local<'_,HashSet<EventId<MouseButtonInput>>>`, but its trait bounds were not satisfied
--> src\interaction.rs:327:54
|
327 | if !old_events.contains(&id) && processed_events.insert(id){
| ^^^^^^
|
:::D:\Programs\Rust\cargo\registry\src\github.com-1ecc6299db9ec823\bevy_ecs-0.10.0\src\event.rs:20:1
|
20 | pub struct EventId<E:Event> {
| ---------------------------- doesn't satisfy `bevy::ecs::event::EventId<MouseButtonInput>:Hash`
|
= note: the following trait bounds were not satisfied:
`bevy::ecs::event::EventId<MouseButtonInput>:Hash`
In the above error message, I am unable to insert an EventId object into a HashSet as MouseButtonInput does not implement Hash. As MouseButtonInput is only being used in a marker, I don't believe it should be relied upon in the Hash implementation; however the derive macro is not smart enough to know this. For this reason, I believe the traits should be implemented manually.
The text was updated successfully, but these errors were encountered:
# Objective
Fixesbevyengine#8528
## Solution
Manually implement `PartialEq`, `Eq`, `PartialOrd`, `Ord`, and `Hash` for `bevy_ecs::event::EventId`.
These new implementations do not rely on the `Event` implementing the same traits allowing `EventId` to be used in more cases.
# Objective
Fixesbevyengine#8528
## Solution
Manually implement `PartialEq`, `Eq`, `PartialOrd`, `Ord`, and `Hash` for `bevy_ecs::event::EventId`.
These new implementations do not rely on the `Event` implementing the same traits allowing `EventId` to be used in more cases.
konsti219
added a commit
to konsti219/bevy
that referenced
this issue
May 3, 2023
# Objective
Fixesbevyengine#8528
## Solution
Manually implement `PartialEq`, `Eq`, `PartialOrd`, `Ord`, and `Hash` for `bevy_ecs::event::EventId`.
These new implementations do not rely on the `Event` implementing the same traits allowing `EventId` to be used in more cases.
Currently,
bevy_ecs::event::EventId
makes use of derive macros for its implementations of a set of traits:This creates an issue when attempting to actually use these implementations (especially that of
Hash
), as it requires them to be implemented on the events themselves; despite the generic only being used in a marker type.It would be better to manually implement these traits to ignore the marker, freeing them up to be used in more places than they are currently:
In the above error message, I am unable to insert an
EventId
object into aHashSet
asMouseButtonInput
does not implementHash
. AsMouseButtonInput
is only being used in a marker, I don't believe it should be relied upon in theHash
implementation; however the derive macro is not smart enough to know this. For this reason, I believe the traits should be implemented manually.The text was updated successfully, but these errors were encountered: