mirror of
https://github.com/bevyengine/bevy
synced 2024-12-24 12:03:14 +00:00
6cc01c1449
# Objective Enums are now reflectable, but are not accessible via reflection paths. This would allow us to do things like: ```rust #[derive(Reflect)] struct MyStruct { data: MyEnum } #[derive(Reflect)] struct MyEnum { Foo(u32, u32), Bar(bool) } let x = MyStruct { data: MyEnum::Foo(123), }; assert_eq!(*x.get_path::<u32>("data.1").unwrap(), 123); ``` ## Solution Added support for enums in reflection paths. ##### Note This uses a simple approach of just getting the field with the given accessor. It does not do matching or anything else to ensure the enum is the intended variant. This means that the variant must be known ahead of time or matched outside the reflection path (i.e. path to variant, perform manual match, and continue pathing). --- ## Changelog - Added support for enums in reflection paths |
||
---|---|---|
.. | ||
enums | ||
impls | ||
serde | ||
array.rs | ||
fields.rs | ||
from_reflect.rs | ||
lib.rs | ||
list.rs | ||
map.rs | ||
path.rs | ||
reflect.rs | ||
std_traits.rs | ||
struct_trait.rs | ||
tuple.rs | ||
tuple_struct.rs | ||
type_info.rs | ||
type_registry.rs | ||
type_uuid.rs | ||
utility.rs |