[Merged by Bors] - bevy_reflect: Fix apply method for Option<T>#5780
Closed
MrGVSV wants to merge 4 commits intobevyengine:mainfrom
Closed
[Merged by Bors] - bevy_reflect: Fix apply method for Option<T>#5780MrGVSV wants to merge 4 commits intobevyengine:mainfrom
apply method for Option<T>#5780MrGVSV wants to merge 4 commits intobevyengine:mainfrom
Conversation
alice-i-cecile
approved these changes
Aug 24, 2022
afonsolage
approved these changes
Aug 24, 2022
mockersf
reviewed
Aug 24, 2022
Member
Author
|
I just added a test which subsequently alerted me of another bug which has been fixed as well. |
mockersf
approved these changes
Aug 24, 2022
alice-i-cecile
approved these changes
Aug 24, 2022
cart
approved these changes
Aug 24, 2022
| }) | ||
| .clone_value() | ||
| .take::<T>() | ||
| .unwrap_or_else(|value| { |
Member
There was a problem hiding this comment.
Seems reasonable for the current impl. Stuff like this makes me want to revisit mixing "dynamic type" reflection and "actual type" reflection. But thats a conversation for another day :)
Member
Author
There was a problem hiding this comment.
Sounds like a good time to revisit bevyengine/rfcs#56 😉
Member
|
bors r+ |
bors bot
pushed a commit
that referenced
this pull request
Aug 24, 2022
# Objective #5658 made it so that `FromReflect` was used as the bound for `T` in `Option<T>`. However, it did not use this change effectively for the implementation of `Reflect::apply` (it was still using `take`, which would fail for Dynamic types). Additionally, the changes were not consistent with other methods within the file, such as the ones for `Vec<T>` and `HashMap<K, V>`. ## Solution Update `Option<T>` to fallback on `FromReflect` if `take` fails, instead of wholly relying on one or the other. I also chose to update the error messages, as they weren't all too descriptive before. --- ## Changelog - Use `FromReflect::from_reflect` as a fallback in the `Reflect::apply` implementation for `Option<T>`
Contributor
|
Pull request successfully merged into main. Build succeeded: |
apply method for Option<T>apply method for Option<T>
maccesch
pushed a commit
to Synphonyte/bevy
that referenced
this pull request
Sep 28, 2022
# Objective bevyengine#5658 made it so that `FromReflect` was used as the bound for `T` in `Option<T>`. However, it did not use this change effectively for the implementation of `Reflect::apply` (it was still using `take`, which would fail for Dynamic types). Additionally, the changes were not consistent with other methods within the file, such as the ones for `Vec<T>` and `HashMap<K, V>`. ## Solution Update `Option<T>` to fallback on `FromReflect` if `take` fails, instead of wholly relying on one or the other. I also chose to update the error messages, as they weren't all too descriptive before. --- ## Changelog - Use `FromReflect::from_reflect` as a fallback in the `Reflect::apply` implementation for `Option<T>`
james7132
pushed a commit
to james7132/bevy
that referenced
this pull request
Oct 28, 2022
# Objective bevyengine#5658 made it so that `FromReflect` was used as the bound for `T` in `Option<T>`. However, it did not use this change effectively for the implementation of `Reflect::apply` (it was still using `take`, which would fail for Dynamic types). Additionally, the changes were not consistent with other methods within the file, such as the ones for `Vec<T>` and `HashMap<K, V>`. ## Solution Update `Option<T>` to fallback on `FromReflect` if `take` fails, instead of wholly relying on one or the other. I also chose to update the error messages, as they weren't all too descriptive before. --- ## Changelog - Use `FromReflect::from_reflect` as a fallback in the `Reflect::apply` implementation for `Option<T>`
ItsDoot
pushed a commit
to ItsDoot/bevy
that referenced
this pull request
Feb 1, 2023
# Objective bevyengine#5658 made it so that `FromReflect` was used as the bound for `T` in `Option<T>`. However, it did not use this change effectively for the implementation of `Reflect::apply` (it was still using `take`, which would fail for Dynamic types). Additionally, the changes were not consistent with other methods within the file, such as the ones for `Vec<T>` and `HashMap<K, V>`. ## Solution Update `Option<T>` to fallback on `FromReflect` if `take` fails, instead of wholly relying on one or the other. I also chose to update the error messages, as they weren't all too descriptive before. --- ## Changelog - Use `FromReflect::from_reflect` as a fallback in the `Reflect::apply` implementation for `Option<T>`
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Objective
#5658 made it so that
FromReflectwas used as the bound forTinOption<T>. However, it did not use this change effectively for the implementation ofReflect::apply(it was still usingtake, which would fail for Dynamic types).Additionally, the changes were not consistent with other methods within the file, such as the ones for
Vec<T>andHashMap<K, V>.Solution
Update
Option<T>to fallback onFromReflectiftakefails, instead of wholly relying on one or the other.I also chose to update the error messages, as they weren't all too descriptive before.
Changelog
FromReflect::from_reflectas a fallback in theReflect::applyimplementation forOption<T>