Skip to content

Commit cfe4034

Browse files
authored
Add Reflection for Wrapping/Saturating types (#11397)
# 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`.
1 parent 1e7e6c9 commit cfe4034

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

crates/bevy_reflect/src/impls/std.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,8 @@ impl_reflect_value!(::core::num::NonZeroI8(
201201
Serialize,
202202
Deserialize
203203
));
204+
impl_reflect_value!(::core::num::Wrapping<T: Clone + Send + Sync>());
205+
impl_reflect_value!(::core::num::Saturating<T: Clone + Send + Sync>());
204206
impl_reflect_value!(::std::sync::Arc<T: Send + Sync>);
205207

206208
// `Serialize` and `Deserialize` only for platforms supported by serde:

crates/bevy_reflect/src/type_uuid_impl.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::ffi::OsString;
1111
use std::{
1212
num::{
1313
NonZeroI128, NonZeroI16, NonZeroI32, NonZeroI64, NonZeroI8, NonZeroIsize, NonZeroU128,
14-
NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize,
14+
NonZeroU16, NonZeroU32, NonZeroU64, NonZeroU8, NonZeroUsize, Saturating, Wrapping,
1515
},
1616
ops::{RangeFrom, RangeFull, RangeInclusive, RangeTo, RangeToInclusive},
1717
path::PathBuf,
@@ -69,6 +69,8 @@ impl_type_uuid!(NonZeroI16, "8744c2ec8a10491fae40f8bafa58b30d");
6969
impl_type_uuid!(NonZeroU16, "c7b8b60780a6495bab4fda2bdfedabcc");
7070
impl_type_uuid!(NonZeroU8, "635ee104ef7947fb9d7f79dad47255a3");
7171
impl_type_uuid!(NonZeroI8, "2d3f1570b7f64779826d44da5c7ba069");
72+
impl_type_uuid!(Saturating<T>, "e9d7c5d5b9e94c9c9c8c8c0f5f3c5c5f");
73+
impl_type_uuid!(Wrapping<T>, "d5b9e94c9c9c8c8c0f5f3c5c5fe9d7c5");
7274
#[cfg(any(unix, windows))]
7375
impl_type_uuid!(OsString, "809e7b3c1ea240979ecd832f91eb842a");
7476
macro_rules! impl_tuple {

0 commit comments

Comments
 (0)