bevy/crates/bevy_reflect/src
MrGVSV 4c194084b4 bevy_reflect: Add GetTypeRegistration impl for reflected tuples (#4226)
# Objective

Reflected tuples do not implement `GetTypeRegistration`, preventing us from registering our tuples, like:

```rust
app.register_type::<(i32, i32)>();
```

This is especially important for things like using #4042 to improve the scene format or implementing #4154 to recursively register fields.

## Solution

Added an implementation to the tuple macro:

```rust
impl<$($name: Reflect + for<'de> Deserialize<'de>),*> GetTypeRegistration for ($($name,)*) {
  fn get_type_registration() -> TypeRegistration {
    let mut registration = TypeRegistration::of::<($($name,)*)>();
    registration.insert::<ReflectDeserialize>(FromType::<($($name,)*)>::from_type());
    registration
  }
}
```

This requires that the tuple's types implement `Deserialize`. This is exactly how `Vec` and `HashMap` handle it:

```rust
impl<T: FromReflect + for<'de> Deserialize<'de>> GetTypeRegistration for Vec<T> {
  fn get_type_registration() -> TypeRegistration {
    let mut registration = TypeRegistration::of::<Vec<T>>();
    registration.insert::<ReflectDeserialize>(FromType::<Vec<T>>::from_type());
    registration
  }
}
```
2022-05-02 18:04:48 +00:00
..
impls bevy_reflect: Added PartialEq to reflected f32 & f64 (#4217) 2022-04-26 19:41:26 +00:00
serde Avoid some format! into immediate format! (#2913) 2021-10-06 18:34:33 +00:00
lib.rs re-enable #[derive(TypeUuid)] for generics (#4118) 2022-04-26 19:41:25 +00:00
list.rs bevy_reflect: IntoIter for DynamicList and DynamicMap (#4108) 2022-04-26 00:17:38 +00:00
map.rs bevy_reflect: IntoIter for DynamicList and DynamicMap (#4108) 2022-04-26 00:17:38 +00:00
path.rs document more of bevy_reflect (#3655) 2022-01-14 19:09:44 +00:00
reflect.rs bevy_reflect: Add as_reflect and as_reflect_mut (#4350) 2022-04-25 13:54:48 +00:00
struct_trait.rs bevy_reflect: Add as_reflect and as_reflect_mut (#4350) 2022-04-25 13:54:48 +00:00
tuple_struct.rs bevy_reflect: Add as_reflect and as_reflect_mut (#4350) 2022-04-25 13:54:48 +00:00
tuple.rs bevy_reflect: Add GetTypeRegistration impl for reflected tuples (#4226) 2022-05-02 18:04:48 +00:00
type_registry.rs Re-enable test_property_type_registration() (#4419) 2022-04-05 18:34:27 +00:00
type_uuid.rs re-enable #[derive(TypeUuid)] for generics (#4118) 2022-04-26 19:41:25 +00:00