-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Make reflect_partial_eq
return more accurate results
#5204
Labels
A-Reflection
Runtime information about types
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
D-Trivial
Nice and easy! A great choice to get started with Bevy
Comments
MrGVSV
added
D-Trivial
Nice and easy! A great choice to get started with Bevy
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
A-Reflection
Runtime information about types
labels
Jul 4, 2022
2 tasks
inodentry
pushed a commit
to IyesGames/bevy
that referenced
this issue
Aug 8, 2022
# Objective Closes bevyengine#5204 ## Solution - Followed @nicopap suggestion on bevyengine#4761 (comment) ## Changelog - [x] Updated [struct_trait](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/struct_trait.rs#L455-L457), [tuple_struct](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/tuple_struct.rs#L366-L368), [tuple](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/tuple.rs#L386), [array](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/array.rs#L335-L337), [list](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/list.rs#L309-L311) and [map](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/map.rs#L361-L363) to return `None` when comparison couldn't be performed. - [x] Updated docs comments to reflect above changes.
james7132
pushed a commit
to james7132/bevy
that referenced
this issue
Oct 28, 2022
# Objective Closes bevyengine#5204 ## Solution - Followed @nicopap suggestion on bevyengine#4761 (comment) ## Changelog - [x] Updated [struct_trait](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/struct_trait.rs#L455-L457), [tuple_struct](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/tuple_struct.rs#L366-L368), [tuple](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/tuple.rs#L386), [array](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/array.rs#L335-L337), [list](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/list.rs#L309-L311) and [map](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/map.rs#L361-L363) to return `None` when comparison couldn't be performed. - [x] Updated docs comments to reflect above changes.
ItsDoot
pushed a commit
to ItsDoot/bevy
that referenced
this issue
Feb 1, 2023
# Objective Closes bevyengine#5204 ## Solution - Followed @nicopap suggestion on bevyengine#4761 (comment) ## Changelog - [x] Updated [struct_trait](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/struct_trait.rs#L455-L457), [tuple_struct](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/tuple_struct.rs#L366-L368), [tuple](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/tuple.rs#L386), [array](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/array.rs#L335-L337), [list](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/list.rs#L309-L311) and [map](https://github.com/bevyengine/bevy/blob/dfe969005264fff54060f9fb148639f80f9cfb29/crates/bevy_reflect/src/map.rs#L361-L363) to return `None` when comparison couldn't be performed. - [x] Updated docs comments to reflect above changes.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-Reflection
Runtime information about types
C-Usability
A targeted quality-of-life change that makes Bevy easier to use
D-Trivial
Nice and easy! A great choice to get started with Bevy
What problem does this solve or what need does it fill?
Currently, all
***_partial_eq
helper methods do something like:bevy/crates/bevy_reflect/src/struct_trait.rs
Lines 455 to 457 in dfe9690
If
field_value.reflect_partial_eq(value)
returnedNone
, it makes more sense for the entire function to returnNone
as this would suggest to the user that the comparison didn't just fail, but couldn't even be performed.However, this is not currently done and instead the functions just return
Some(false)
.What solution would you like?
None
on a matchedNone
:bevy/crates/bevy_reflect/src/struct_trait.rs
Lines 455 to 457 in dfe9690
bevy/crates/bevy_reflect/src/tuple_struct.rs
Lines 366 to 368 in dfe9690
bevy/crates/bevy_reflect/src/tuple.rs
Line 386 in dfe9690
bevy/crates/bevy_reflect/src/array.rs
Lines 335 to 337 in dfe9690
bevy/crates/bevy_reflect/src/list.rs
Lines 309 to 311 in dfe9690
bevy/crates/bevy_reflect/src/map.rs
Lines 361 to 363 in dfe9690
None
value might be returned)What alternative(s) have you considered?
Not doing this. Most usages of these functions and
reflect_partial_eq
itself useunwrap_or_default()
anyways, so they would not be affected by such a change. However, adding this in allows us to give a bit more info to the users who want it.Additional context
Originally brought to attention by @nicopap in #4761 (comment).
The text was updated successfully, but these errors were encountered: