From 0a05f93415513bc083f3a66bea34a4a5a38cd0a2 Mon Sep 17 00:00:00 2001 From: Gino Valente Date: Sun, 19 May 2024 18:20:14 -0700 Subject: [PATCH] Add test for generic types --- crates/bevy_reflect/src/lib.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/crates/bevy_reflect/src/lib.rs b/crates/bevy_reflect/src/lib.rs index 44c15d268f23c1..e354e77beb9cc6 100644 --- a/crates/bevy_reflect/src/lib.rs +++ b/crates/bevy_reflect/src/lib.rs @@ -807,6 +807,18 @@ mod tests { let clone = value.reflect_clone().expect("should reflect_clone struct"); assert_eq!(value, clone.take::().unwrap()); + // Generic Struct + #[derive(Reflect, Debug, PartialEq)] + struct Bar(T, #[reflect(ignore, clone)] PhantomData); + #[derive(TypePath, Debug, PartialEq)] + struct Baz; + + let value = Bar::(123, PhantomData); + let clone = value + .reflect_clone() + .expect("should reflect_clone generic struct"); + assert_eq!(value, clone.take::>().unwrap()); + // Tuple let foo = (123, 4.56); let clone = foo.reflect_clone().expect("should reflect_clone tuple");