Skip to content
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

Fluent builder methods for bevy_reflect ParsedPaths. #13227

Open
viridia opened this issue May 4, 2024 · 1 comment
Open

Fluent builder methods for bevy_reflect ParsedPaths. #13227

viridia opened this issue May 4, 2024 · 1 comment
Labels
A-Reflection Runtime information about types C-Enhancement A new feature D-Straightforward Simple bug fixes and API improvements, docs, test and examples X-Uncontroversial This work is generally agreed upon

Comments

@viridia
Copy link
Contributor

viridia commented May 4, 2024

What problem does this solve or what need does it fill?

I'd like a set of builder methods for ParsedPaths. Rather than (or in addition to) parsing paths from strings, I'd like to be able to construct paths using a fluent API. Basically I am building a tree of widgets by recursively walking the reflection data, and as I visit each field I want to construct a new path which is the concatenation of the parent path with the path segment for the field being visited.

What solution would you like?

Given a "base path" (which may be empty), I want to generate a new path which is the concatenation of the base plus a new element, which could be a name, index and so on. Similar to path.join() for directories.

What alternative(s) have you considered?

I could do this by manipulating the Vec directly, but fluent methods would be cleaner.

@viridia viridia added C-Enhancement A new feature S-Needs-Triage This issue needs to be labelled labels May 4, 2024
@james7132 james7132 added A-Reflection Runtime information about types X-Uncontroversial This work is generally agreed upon and removed S-Needs-Triage This issue needs to be labelled labels May 12, 2024
@viridia
Copy link
Contributor Author

viridia commented May 24, 2024

@MrGVSV Here's a rough sketch of what I am thinking of:

let path = ParsedPath::new()
    .push_field("abc")
    .push_list_index(0)
    .join(other_path);

Whether push mutates self, or generates a new path I'm open either way.

@MrGVSV MrGVSV added the D-Straightforward Simple bug fixes and API improvements, docs, test and examples label May 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Reflection Runtime information about types C-Enhancement A new feature D-Straightforward Simple bug fixes and API improvements, docs, test and examples X-Uncontroversial This work is generally agreed upon
Projects
None yet
Development

No branches or pull requests

3 participants