bevyengine / bevyengine/bevy

Easy reflection type traversal utils

Open
#14,847 2 comments 1 reaction 0 assignees View on GitHub
A-Reflection C-Feature D-Complex
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

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

Currently, it is non-trivial to search for and patch a specific type nested deep inside a `dyn Reflect`.

## What solution would you like?

Add an `iter_children` (name bikesheddable) iterator function on `Reflect` that returns a `ChildrenIter` (name bikesheddable) over all *direct* children. `ChildrenIter` will be an enum with the same same variants as `ReflectKind`, but it also holds a reference to the iterator of the erased data trait.
e.g. `Struct(IterFields<'a>)`
This is needed for `Reflect` to still be object-safe.
It should also exist an `iter_children_mut`, which is blocked on #14846

## What alternative(s) have you considered?

Writing that myself.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.