bevy/crates/bevy_reflect/src
Nicola Papale 7083f0d593
Make it so ParsedPath can be passed to GetPath (#9373)
# Objective

- Unify the `ParsedPath` and `GetPath` APIs. They weirdly didn't play
well together.
- Make `ParsedPath` and `GetPath` API easier to use

## Solution

- Add the `ReflectPath` trait.
- `GetPath` methods now accept an `impl ReflectPath<'a>` instead of a
`&'a str`, this mean it also can accepts a `&ParsedPath`
- Make `GetPath: Reflect` and use default impl for `Reflect` types.
- Add `GetPath` and `ReflectPath` to the `bevy_reflect` prelude

---

## Changelog

- Add the `ReflectPath` trait.
- `GetPath` methods now accept an `impl ReflectPath<'a>` instead of a
`&'a str`, this mean it also can accept a `&ParsedPath`
- Make `GetPath: Reflect` and use default impl for `Reflect` types.
- Add `GetPath` and `ReflectPath` to the `bevy_reflect` prelude

## Migration Guide

`GetPath` now requires `Reflect`. This reduces a lot of boilerplate on
bevy's side. If you were implementing manually `GetPath` on your own
type, please get in touch!

`ParsedPath::element[_mut]` isn't an inherent method of `ParsedPath`,
you must now import `ReflectPath`. This is only relevant if you weren't
importing the bevy prelude.

```diff
-use bevy::reflect::ParsedPath;
+use bevy::reflect::{ParsedPath, ReflectPath};

 parsed_path.element(reflect_type).unwrap()
 parsed_path.element(reflect_type).unwrap()
2023-08-25 14:32:41 +00:00
..
enums bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
impls Implement reflect trait on new glam types (I64Vec and U64Vec) (#9281) 2023-07-31 19:18:21 +00:00
path Make it so ParsedPath can be passed to GetPath (#9373) 2023-08-25 14:32:41 +00:00
serde bevy_reflect: FromReflect Ergonomics Implementation (#6056) 2023-06-29 01:31:34 +00:00
array.rs Fix typos throughout the project (#9090) 2023-07-10 00:11:51 +00:00
fields.rs
from_reflect.rs Fix typos throughout the project (#9090) 2023-07-10 00:11:51 +00:00
lib.rs Make it so ParsedPath can be passed to GetPath (#9373) 2023-08-25 14:32:41 +00:00
list.rs Fix typos throughout the project (#9090) 2023-07-10 00:11:51 +00:00
map.rs Fix CI for Rust 1.72 (#9562) 2023-08-25 12:34:24 +00:00
reflect.rs Reflect now requires DynamicTypePath. Remove Reflect::get_type_path() (#8764) 2023-06-06 17:23:58 +00:00
std_traits.rs
struct_trait.rs Fix CI for Rust 1.72 (#9562) 2023-08-25 12:34:24 +00:00
tuple_struct.rs Reflect now requires DynamicTypePath. Remove Reflect::get_type_path() (#8764) 2023-06-06 17:23:58 +00:00
tuple.rs Reflect now requires DynamicTypePath. Remove Reflect::get_type_path() (#8764) 2023-06-06 17:23:58 +00:00
type_info.rs Reflect now requires DynamicTypePath. Remove Reflect::get_type_path() (#8764) 2023-06-06 17:23:58 +00:00
type_path.rs Fix typos throughout the project (#9090) 2023-07-10 00:11:51 +00:00
type_registry.rs Fixed several missing links in docs. (#8117) 2023-04-23 17:28:36 +00:00
type_uuid_impl.rs implement TypeUuid for primitives and fix multiple-parameter generics having the same TypeUuid (#6633) 2023-02-16 17:09:44 +00:00
type_uuid.rs implement TypeUuid for primitives and fix multiple-parameter generics having the same TypeUuid (#6633) 2023-02-16 17:09:44 +00:00
utility.rs Fix typos throughout the project (#9090) 2023-07-10 00:11:51 +00:00