-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
C-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or change
Description
With the merging of @cart's #926, the hash
method of bevy::prelude::Reflect
now collides with the hash
method from std::hash::Hash
. You can workaround by disambiguating, so this isn't a showstopper. I'm reporting it in the hopes that there's an easy tweak to avoid having to do the workaround. If not, no big deal - and I'm fine closing this.
With the following imports:
use bevy::prelude::*;
use std::hash::Hash;
When you attempt to call the hash
method on a primitive value like an integer (which is something you might want to do within an implementation of the Hash trait for a struct, such as on line 59 here -- PlayerID
is a newtype over usize
):
You get this error:
error[E0034]: multiple applicable items in scope
--> src/player/collision.rs:58:23
|
58 | player_id.hash(state);
| ^^^^ multiple `hash` found
|
= note: candidate #1 is defined in an impl of the trait `Hash` for the type `usize`
= note: candidate #2 is defined in an impl of the trait `bevy::prelude::Reflect` for the type `usize`
help: disambiguate the associated function for candidate #1
|
58 | Hash::hash(&player_id, state);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
help: disambiguate the associated function for candidate #2
|
58 | bevy::prelude::Reflect::hash(&player_id, state);
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0034`.
The workaround is to change player_id.hash(state);
to Hash::hash(&player_id, state);
to disambiguate.
Metadata
Metadata
Assignees
Labels
C-Code-QualityA section of code that is hard to understand or changeA section of code that is hard to understand or change