-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add the ability to manually create ParsedPaths (+ cleanup) #11029
Conversation
@viridia opinions on whether we should do this? |
@alice-i-cecile Different kind of "path" I think. I don't think we're talking about filesystem paths here. |
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.
I'd like to rename the error type, but this seems like a reasonable API to expose and the engineering is solid.
I reviewed the code, I posted my feedbacks as a PR on the doonv/bevy repo, see doonv#2 |
* Split the error code into its own module * Use a newtype for the offset, instead of `Option<usize>` (16 bytes), we have a `usize` (8 bytes). * Make a few error types private, so that they don't need to be documented. * Make `AccessError` a `struct` with an `access` and `offset` fields.
@nicopap Why did you decide to make the inner error types private? |
I prefer making them private because:
But of course there are advantages to exposing them:
I think it's probably better to expose them, now that I write this down. But eh, I don't want to write the doc :P |
No strong feelings on whether or not those are public :) @nicopap if you're happy enough with this now, leave an approval and I'll merge this in. |
I certainly want them public for my use case, I'll make a commit which makes them public. |
Refactor changes:
@nicopap can you review this now? |
…e#11029) # Objective I'm working on a developer console plugin, and I wanted to get a field/index of a struct/list/tuple. My command parser already parses member expressions and all that, so I wanted to construct a `ParsedPath` manually, but it's all private. ## Solution Make the internals of `ParsedPath` public and add documentation for everything, and I changed the boxed slice inside `ParsedPath` to a vector for more flexibility. I also did a bunch of code cleanup. Improving documentation, error messages, code, type names, etc. --- ## Changelog - Added the ability to manually create `ParsedPath`s from their elements, without the need of string parsing. - Improved `ReflectPath` error handling. ## Migration Guide - `bevy::reflect::AccessError` has been refactored. That should be it I think, everything else that was changed was private before this PR. --------- Co-authored-by: Nicola Papale <nicopap@users.noreply.github.com>
Objective
I'm working on a developer console plugin, and I wanted to get a field/index of a struct/list/tuple. My command parser already parses member expressions and all that, so I wanted to construct a
ParsedPath
manually, but it's all private.Solution
Make the internals of
ParsedPath
public and add documentation for everything, and I changed the boxed slice insideParsedPath
to a vector for more flexibility.I also did a bunch of code cleanup. Improving documentation, error messages, code, type names, etc.
Changelog
ParsedPath
s from their elements, without the need of string parsing.ReflectPath
error handling.Migration Guide
bevy::reflect::AccessError
has been refactored.That should be it I think, everything else that was changed was private before this PR.