-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
from_reflect_or_world
also try ReflectDefault
and improve so…
…me comments and panic messages (#12499) # Objective - `from_reflect_or_world` is an internal utilty used in the implementations of `ReflectComponent` and `ReflectBundle` to create a `T` given a `&dyn Reflect` by trying to use `FromReflect`, and if that fails it falls back to `ReflectFromWorld` - reflecting `FromWorld` is not intuitive though: often it is implicitly implemented by deriving `Default` so people might not even be aware of it. - the panic messages mentioning `ReflectFromWorld` are not directly correlated to what the user would have to do (reflect `FromWorld`) ## Solution - Also check for `ReflectDefault` in addition to `ReflectFromWorld`. - Change the panic messages to mention the reflected trait rather than the `Reflect*` types. --- ## Changelog - `ReflectComponent` and `ReflectBundle` no longer require `T: FromReflect` but instead only `T: Reflect`. - `ReflectComponent` and `ReflectBundle` will also work with types that only reflected `Default` and not `FromWorld`. ## Migration Guide - `ReflectBundle::insert` now requires an additional `&TypeRegistry` parameter.
- Loading branch information
Showing
4 changed files
with
77 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters