bevy
bevy copied to clipboard
Implement `Reflect` for `Box<[T]>`
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<T>, but I'd prefer Box<[T]>.
I guess its either:
- adding some
TypeInfo::FixedSizeListtype (something like that) - use
TypeInfo::Listand override thepushmethod to panic, and defininginsertandremoveto actually doset_at_indexandnullify_at_index(take the element and replace it with some default value) - bite the bullet and use
Vec<T>