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.
This commit is contained in:
Lubba64 2024-08-22 19:01:38 -04:00 committed by GitHub
parent 510fce9af3
commit f9fbd08f9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 1 additions and 20 deletions

View file

@ -107,6 +107,7 @@ impl_reflect_value!(::core::ops::RangeFrom<T: Clone + Send + Sync>());
impl_reflect_value!(::core::ops::RangeTo<T: Clone + Send + Sync>());
impl_reflect_value!(::core::ops::RangeToInclusive<T: Clone + Send + Sync>());
impl_reflect_value!(::core::ops::RangeFull());
impl_reflect_value!(::std::ops::Bound<T: Clone + Send + Sync>());
impl_reflect_value!(::bevy_utils::Duration(
Debug,
Hash,

View file

@ -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<i32>: Reflect);
#[reflect_remote(std::collections::Bound<T>)]
enum MyBound<T> {
Included(T),
Excluded(T),
Unbounded,
}
#[derive(Reflect)]
struct MyType {
#[reflect(remote = MyBound<String>)]
bound: std::collections::Bound<String>,
}
}
#[cfg(feature = "glam")]
mod glam {
use super::*;