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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions crates/bevy_reflect/src/impls/std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ impl_reflect_value!(::core::num::NonZeroI8(
Serialize,
Deserialize
));
impl_reflect_value!(::core::num::Wrapping<T: Clone + Send + Sync>());
impl_reflect_value!(::core::num::Saturating<T: Clone + Send + Sync>());
Comment on lines +204 to +205
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.

impl_reflect_value!(::std::sync::Arc<T: Send + Sync>);

// `Serialize` and `Deserialize` only for platforms supported by serde:
Expand Down
4 changes: 3 additions & 1 deletion crates/bevy_reflect/src/type_uuid_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::ffi::OsString;
use std::{
num::{
NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU128,
NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize,
NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize, Saturating, Wrapping,
},
ops::{RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive},
path::PathBuf,
Expand Down Expand Up @@ -69,6 +69,8 @@ impl_type_uuid!(NonZeroI16, "8744c2ec8a10491fae40f8bafa58b30d");
impl_type_uuid!(NonZeroU16, "c7b8b60780a6495bab4fda2bdfedabcc");
impl_type_uuid!(NonZeroU8, "635ee104ef7947fb9d7f79dad47255a3");
impl_type_uuid!(NonZeroI8, "2d3f1570b7f64779826d44da5c7ba069");
impl_type_uuid!(Saturating<T>, "e9d7c5d5b9e94c9c9c8c8c0f5f3c5c5f");
impl_type_uuid!(Wrapping<T>, "d5b9e94c9c9c8c8c0f5f3c5c5fe9d7c5");
#[cfg(any(unix, windows))]
impl_type_uuid!(OsString, "809e7b3c1ea240979ecd832f91eb842a");
macro_rules! impl_tuple {
Expand Down