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

Add Reflection for Wrapping/Saturating types #11397

Merged
merged 1 commit into from
Jan 22, 2024
Merged

Add Reflection for Wrapping/Saturating types #11397

merged 1 commit into from
Jan 22, 2024

Conversation

johnbchron
Copy link
Contributor

@johnbchron johnbchron commented Jan 18, 2024

Objective

  • Extend reflection to the standard library's Wrapping and Saturating generic types.

This wasn't my use-case but someone in the discord was surprised that this wasn't already done. I decided to make a PR because the other std::num items were reflected and if there's a reason to exclude Wrapping and Saturating, I am unaware of it.

Solution

Trivial fix


Changelog

Implemented Reflect for Wrapping<T> and Saturating<T> from std::num.

Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@MrGVSV MrGVSV added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Reflection Runtime information about types labels Jan 18, 2024
Comment on lines +204 to +205
impl_reflect_value!(::core::num::Wrapping<T: Clone + Send + Sync>());
impl_reflect_value!(::core::num::Saturating<T: Clone + Send + Sync>());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: It might be nice to add a test for these since derives on generics can be a bit wonky haha. Not required though since I believe other reflect_value generics are tested

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use static_assertions similar to how it was used #11407. Check out the assert_impl_all macro.

@MrGVSV
Copy link
Member

MrGVSV commented Jan 18, 2024

LGTM! We could consider forcing additional bounds (i.e. PartialEq) that we know most wrapped/saturated types implement so that we can register additional type data. But for now, I think we should leave it as is.

@MrGVSV MrGVSV added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Jan 18, 2024
Copy link
Member

@james7132 james7132 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fill out the full PR description template. We use tools to build our changelogs and migration guides from them. No migration guide is needed here, but the changelog should be appropriately filled out.

@johnbchron
Copy link
Contributor Author

the changelog should be appropriately filled out.

Done.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jan 22, 2024
Merged via the queue into bevyengine:main with commit cfe4034 Jan 22, 2024
26 checks passed
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 S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

6 participants