-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update from_reflect
to return a Result
#7075
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good so far. I think the main thing that should be addressed (imo anyways) is making the error struct an enum instead.
I have chosen the name To differentiate between The same cannot be done for the target type since calling |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few more comments. Mostly documentation, organization, and other nitpicks.
I think we should also add some tests as well, to ensure that we get the proper errors from their corresponding cases. Could we add some to the from_reflect
module? (We could continue to use lib.rs
for this, but that file is already massive as is haha so it might be nicer to put them in their relevant module.)
@elbertronnie are you interested in rebasing this PR? If not, we can mark this as |
@MrGVSV I am quite busy in other things currently. I can only work on this after about a month. If someone is willing to work on it now then I would suggest to mark it as |
I found a blog a year back that had a good syntax for error messages related to reflection of composed structures. I think this could be useful to when implementing this PR. This is much better than the error messages that are currently in this PR. |
I think we'll be okay to wait (unless you actually don't want to do it yourself, not trying to put any pressure on you haha). I’m planning to do some things with |
Wouldn't |
Backlog cleanup: nice one, looks like this has a future so leaving it be! |
Will check in again on this one in the new year 🙂 |
@elbertronnie I think now would be a good time to resolve merge conflicts if you are still interested |
After looking at the how bevy_reflect has changed over time, resolving merge conflicts felt harder than just writing code again. Since a lot parts like |
Objective
FromReflect
trait #5967.Solution
ReflectKind
which contains all the "kinds" of types inReflect
reflect_kind
toReflect
which returns the appropriate kindFromReflectError
from_reflect
to return a Result with the above Errorfrom_reflect
Changelog
FromReflect::from_reflect
to a Result withFromReflectError
as the Error typeReflectKind
which contains all the "kinds" of types inReflect
reflect_kind(&self) -> ReflectKind
toReflect
which returns the appropriate kindMigration Guide
from_reflect(...)
withfrom_reflect(...).ok()
Reflect
manually, add a new methodreflect_kind(&self) -> ReflectKind
to it