From f9fbd08f9f520f2d139fc3d3fdac3d7e686e58b1 Mon Sep 17 00:00:00 2001 From: Lubba64 <75751722+Lubba-64@users.noreply.github.com> Date: Thu, 22 Aug 2024 19:01:38 -0400 Subject: [PATCH] Implement `Reflect` for `std::ops::Bound` (#14861) # Objective - Fixes #14844 ## Solution - implement reflect using the `impl_reflect_value` macro ## Testing - I wrote a test locally to understand and learn how reflection worked on a basic level and to confirm that yes indeed the bound struct could use the reflection traits that have been implemented for it. note: I did remove a line that asked for bound to not have reflect implemented in a test, since that's the point of this PR and the test worked without the line so I am not sure what that was about, not sure if that uncovers a deeper issue or not. --- crates/bevy_reflect/src/impls/std.rs | 1 + crates/bevy_reflect/src/lib.rs | 20 -------------------- 2 files changed, 1 insertion(+), 20 deletions(-) diff --git a/crates/bevy_reflect/src/impls/std.rs b/crates/bevy_reflect/src/impls/std.rs index 7aae12a699..6320090e6d 100644 --- a/crates/bevy_reflect/src/impls/std.rs +++ b/crates/bevy_reflect/src/impls/std.rs @@ -107,6 +107,7 @@ impl_reflect_value!(::core::ops::RangeFrom()); impl_reflect_value!(::core::ops::RangeTo()); impl_reflect_value!(::core::ops::RangeToInclusive()); impl_reflect_value!(::core::ops::RangeFull()); +impl_reflect_value!(::std::ops::Bound()); impl_reflect_value!(::bevy_utils::Duration( Debug, Hash, diff --git a/crates/bevy_reflect/src/lib.rs b/crates/bevy_reflect/src/lib.rs index fca875b70b..941105a851 100644 --- a/crates/bevy_reflect/src/lib.rs +++ b/crates/bevy_reflect/src/lib.rs @@ -2922,26 +2922,6 @@ bevy_reflect::tests::Test { ); } - #[test] - fn should_reflect_external_crate_type() { - // This test relies on the external type not implementing `Reflect`, - // so let's just double-check that it does not - assert_not_impl_all!(std::collections::Bound: Reflect); - - #[reflect_remote(std::collections::Bound)] - enum MyBound { - Included(T), - Excluded(T), - Unbounded, - } - - #[derive(Reflect)] - struct MyType { - #[reflect(remote = MyBound)] - bound: std::collections::Bound, - } - } - #[cfg(feature = "glam")] mod glam { use super::*;