API to access derived types from TypeRegistration
- 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?
I'm working on an asset loader that includes names of Rust types, including derived types such as arrays. I need a reflection API which allow me to find a derived type: given a `TypeRegistration` for T, return a `TypeRegistration` or `TypeId` for `T[]`.
Ideally this would be extended to other kinds of derived types as well, such as `T` -> `Option`.
## What solution would you like?
Not sure what would work best, but something like `TypeRegistration::derive_array() -> TypeRegistration`.
For things like `Option` it gets a bit tricky because you can't specialize a template at runtime (well, maybe with dynamic types, I'm not sure). So you'd have to let the registry know in advance which types you intended to specialize.
## What alternative(s) have you considered?
The only workaround is to pre-register all derived types in Rust and give them names. So if you want a list of `Item`, you have to create an `ItemList` type. This is fairly cumbersome.
Contributor guide
Research direction
Start by reading TypeRegistration and the surrounding reflection and type-registry APIs. Define the supported derived-type cases, beginning with arrays, and resolve how runtime specialization such as Option should be represented or registered. Done means the API design and supported behavior are clear for callers needing derived type registrations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100