`path` in bevy_reflect doesn't support traversing into a map
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
## What problem does this solve or what need does it fill?
`bevy_reflect` allows path strings, e.g.
```rust
let value = *foo.get_path::("d[0].value").unwrap();
```
The `d[0]` in the above path is indexing into the `0th` entry of the list-like field `d`.
There is no equivalent notation for indexing into a map-like field.
## What solution would you like?
```rust
// Maps use syntax {'key'} to differentiate from list syntax [idx].
let value = *foo.get_path::("m{'key'}.value").unwrap();
```
## What alternative(s) have you considered?
- It could use the same notation as lists, but that could be confusing, e.g.
```rust
let value = *foo.get_path::("m[key].value").unwrap();
```
- Maybe there's no need for the quotes?
```rust
let value = *foo.get_path::("m{key}.value").unwrap();
```
- I suppose not adding support for this at all is another option.
## Additional context
n/a
Contributor guide
Research direction
Start at the bevy_reflect get_path API and trace how the existing d[0] list traversal is parsed and resolved. Decide the map-path syntax from the alternatives in the issue, then add traversal for map-like fields and verify that a path such as m{'key'}.value resolves correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100