bevy/crates/bevy_reflect/src
MrGVSV 15acd6f45d bevy_reflect: Small refactor and default Reflect methods (#4739)
# Objective

Quick followup to #4712.

While updating some [other PRs](https://github.com/bevyengine/bevy/pull/4218), I realized the `ReflectTraits` struct could be improved. The issue with the current implementation is that `ReflectTraits::get_xxx_impl(...)` returns just the _logic_ to the corresponding `Reflect` trait method, rather than the entire function.

This makes it slightly more annoying to manage since the variable names need to be consistent across files. For example, `get_partial_eq_impl` uses a `value` variable. But the name "value" isn't defined in the `get_partial_eq_impl` method, it's defined in three other methods in a completely separate file.

It's not likely to cause any bugs if we keep it as it is since differing variable names will probably just result in a compile error (except in very particular cases). But it would be useful to someone who wanted to edit/add/remove a method.

## Solution

Made `get_hash_impl`, `get_partial_eq_impl` and `get_serialize_impl` return the entire method implementation for `reflect_hash`, `reflect_partial_eq`, and `serializable`, respectively.

As a result of this, those three `Reflect` methods were also given default implementations. This was fairly simple to do since all three could just be made to return `None`.

---

## Changelog

* Small cleanup/refactor to `ReflectTraits` in `bevy_reflect_derive`
* Gave `Reflect::reflect_hash`, `Reflect::reflect_partial_eq`, and `Reflect::serializable` default implementations
2022-05-18 12:26:11 +00:00
..
impls bevy_reflect: Small refactor and default Reflect methods (#4739) 2022-05-18 12:26:11 +00:00
serde bevy_reflect: Reflect arrays (#4701) 2022-05-13 01:13:30 +00:00
array.rs Nightly clippy fixes (#3491) 2022-05-17 04:38:03 +00:00
lib.rs bevy_reflect: Reflect arrays (#4701) 2022-05-13 01:13:30 +00:00
list.rs bevy_reflect: Reflect arrays (#4701) 2022-05-13 01:13:30 +00:00
map.rs bevy_reflect: Small refactor and default Reflect methods (#4739) 2022-05-18 12:26:11 +00:00
path.rs document more of bevy_reflect (#3655) 2022-01-14 19:09:44 +00:00
reflect.rs bevy_reflect: Small refactor and default Reflect methods (#4739) 2022-05-18 12:26:11 +00:00
std_traits.rs add #[reflect(Default)] to create default value for reflected types (#3733) 2022-05-03 19:20:13 +00:00
struct_trait.rs bevy_reflect: Small refactor and default Reflect methods (#4739) 2022-05-18 12:26:11 +00:00
tuple_struct.rs bevy_reflect: Small refactor and default Reflect methods (#4739) 2022-05-18 12:26:11 +00:00
tuple.rs bevy_reflect: Small refactor and default Reflect methods (#4739) 2022-05-18 12:26:11 +00:00
type_registry.rs create mutable versions of TypeRegistry methods (#4484) 2022-05-09 13:37:38 +00:00
type_uuid.rs re-enable #[derive(TypeUuid)] for generics (#4118) 2022-04-26 19:41:25 +00:00