bevyengine / bevyengine/bevy

Flatten attribute for world queries & system params.

Open
#11,858 6 comments 1 reaction 0 assignees View on GitHub
A-ECS C-Feature
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?
Make nested world queries & system params more ergonomic to work with.

## What solution would you like?
Add a `flatten` attribute that flattens all nesting.

## What alternative(s) have you considered?
Destructing with pattern syntax. Gets ugly and messy quickly & doesn't work for `&mut Q` terms because the `Mut` item has a private field.

## Additional context
Example of expected behavior:
```rust
#[derive(WorldQuery)]
struct A {
x: &'static X,
y: &'static Y,
}

#[derive(WorldQuery)]
struct B {
z: &'static Z,
w: &'static W,
}

#[derive(WorldQuery)]
#[flatten]
struct C {
a: A,
b: B,
}

// `CItem` should look like:
struct CItem<'a> {
x: &'a X,
y: &'a Y,
z: &'a Z,
w: &'a W,
}
```

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.