Skip to content
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

Closed
2 tasks
MrGVSV opened this issue Jul 4, 2022 · 0 comments
Closed
2 tasks

Make reflect_partial_eq return more accurate results #5204

MrGVSV opened this issue Jul 4, 2022 · 0 comments
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
Copy link
Member

MrGVSV commented Jul 4, 2022

What problem does this solve or what need does it fill?

Currently, all ***_partial_eq helper methods do something like:

if let Some(false) | None = field_value.reflect_partial_eq(value) {
return Some(false);
}

If field_value.reflect_partial_eq(value) returned None, it makes more sense for the entire function to return None 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?

  • Update the following code to return None on a matched None:
  • Additionally, doc comments may need to be updated to reflect this change (or at least indicate why a None value might be returned)

What alternative(s) have you considered?

Not doing this. Most usages of these functions and reflect_partial_eq itself use unwrap_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).

@MrGVSV 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
@bors bors bot closed this as completed in 40982cd Jul 5, 2022
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant