Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a const constructor for ChainSystem #5914

Closed
nicopap opened this issue Sep 8, 2022 · 0 comments
Closed

Add a const constructor for ChainSystem #5914

nicopap opened this issue Sep 8, 2022 · 0 comments
Labels
A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible

Comments

@nicopap
Copy link
Contributor

nicopap commented Sep 8, 2022

What problem does this solve or what need does it fill?

Currently, it is impossible to define system chains in a const variable such as:

fn sys1() -> Out {
}
fn sys2(In(out): In<Out>) {
}
const systems: ChainSystem<???> = ChainSystem::new(sys1, sys2);

Such pattern would allows proc macros such as bevy_mod_sysfail
to be much more flexible, for example allowing arbitrary system for
handling system output.

What solution would you like?

ChainSystem currently doesn't have a const constructor. What
need to be done to implement such a constructor is:

  • Define a non-trait public const constructor for ChainSystem (pub const fn new(…) -> Self)
  • That constructor, unlike the existing ones, must not rely on trait methods, but rather
    directly call const functions on concrete types/type parameters.

What alternative(s) have you considered?

The current workaround used by bevy_mod_sysfail is to not allow arbitrary
system error handlers, and just insert the error handling code into the system
marked with the attribute macro.

Directly using ChainSystem would allow simplifying the proc macro code as well.

Additional context

This was discussed on discord.

@nicopap nicopap added C-Feature A new feature, making something new possible A-ECS Entities, components, systems, and events labels Sep 8, 2022
bors bot pushed a commit that referenced this issue Dec 25, 2022
# Objective

Fix #5914.

`PipeSystem` cannot be constructed in `const` contexts.

## Solution

Add a const `PipeSystem::new` function.
@bors bors bot closed this as completed in 48b4a45 Dec 25, 2022
alradish pushed a commit to alradish/bevy that referenced this issue Jan 22, 2023
# Objective

Fix bevyengine#5914.

`PipeSystem` cannot be constructed in `const` contexts.

## Solution

Add a const `PipeSystem::new` function.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

Fix bevyengine#5914.

`PipeSystem` cannot be constructed in `const` contexts.

## Solution

Add a const `PipeSystem::new` function.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant