bevyengine / bevyengine/bevy

Implement `Reflect` for `Box<[T]>`

Open
#11,570 2 comments 1 reaction 0 assignees View on GitHub
A-Reflection C-Feature
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?

For immutable arrays with variable runtime len, it's idiomatic to use `Box<[T]>` type.

## What solution would you like?

Similarly to an array `[T; N]`, I should be able to derive `Reflect` on types that contain `Box<[T]>`.
I'd send an MR with this feature, except I was not sure whether this type fit better `TypeInfo::List` or `TypeInfo::Array`.
The issue with the former is that there musn't be any appends, so cannot implement `List` due to required `insert` and `remove.
The issue with the latter is that `Typed::type_info` requires the capacity to be known without any reference to self.

## What alternative(s) have you considered?

I could use `Vec`, but I'd prefer `Box<[T]>`.

Contributor guide

Open the contributing guide

Research direction

Start by tracing the existing Reflect support for [T; N], Box, and Vec, then inspect TypeInfo::List, TypeInfo::Array, and Typed::type_info. Decide which representation fits Box<[T]> without permitting append or remove operations, and verify that types containing it can derive Reflect.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.