Skip to content

Commit

Permalink
Add test for generic types
Browse files Browse the repository at this point in the history
  • Loading branch information
MrGVSV committed May 20, 2024
1 parent 7bec36e commit 0a05f93
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/bevy_reflect/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,18 @@ mod tests {
let clone = value.reflect_clone().expect("should reflect_clone struct");
assert_eq!(value, clone.take::<Foo>().unwrap());

// Generic Struct
#[derive(Reflect, Debug, PartialEq)]
struct Bar<T, U>(T, #[reflect(ignore, clone)] PhantomData<U>);
#[derive(TypePath, Debug, PartialEq)]
struct Baz;

let value = Bar::<usize, Baz>(123, PhantomData);
let clone = value
.reflect_clone()
.expect("should reflect_clone generic struct");
assert_eq!(value, clone.take::<Bar<usize, Baz>>().unwrap());

// Tuple
let foo = (123, 4.56);
let clone = foo.reflect_clone().expect("should reflect_clone tuple");
Expand Down

0 comments on commit 0a05f93

Please sign in to comment.