bevyengine / bevyengine/bevy

Storing `Layout` for `Reflect` types

Open
#17,498 1 comment 0 reactions 0 assignees View on GitHub
A-Reflection C-Feature D-Modest S-Ready-For-Implementation
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?

It allows for lower level manipulation, working with custom allocators in the context of dynamic types etc.

## What solution would you like?

Something along the lines of:
```rust
Reflect::layout(dyn_type) -> Layout
```

Or:
```rust
let layout: Layout = dyn_type.get_represented_type_info().unwrap().layout()
```

Maybe `Optional` instead if this is too restrictive

## What alternative(s) have you considered?

- Storing a custom `TypeData` but it requires registering it for all foreign types as well, not really tractable
- Adding a `Sized` bound to `Reflect` but not sure if that's possible

## Additional context

N/A

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the Reflect and get_represented_type_info APIs named in the issue, along with Rust's Layout type and the constraints around dynamically represented types. Determine whether the API should return Layout or an optional value, and document the supported cases and expected behavior before implementation.

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
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.