Skip to content

Allow non-static references as system Input in systems that are ran directly #9584

@ItsDoot

Description

@ItsDoot

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

Directly ran systems (i.e. one-shot systems) currently effectively require a 'static bound on the System::In associated type, preventing one from passing (non-'static) references as input to a system via System::run:

fn run(&mut self, input: Self::In, world: &mut World) -> Self::Out {

Being able to pass non-'static references to one-shot systems would likely allow us to create full systems as egui widgets, an extension of #5522's rudimentary WidgetSystem into full-featured (exclusive) Systems, for example.

Given that System::In is only ever used as a function argument, it should be possible to implement this in a way that doesn't lose trait objects? I did some experimental implementing of this recently by turning it into a GAT, but ran into the trait object issue and haven't attempted since.

What solution would you like?

For systems that are ran directly (one-shot systems), allow passing non-'static references as system input.

What alternative(s) have you considered?

Clone objects that need to be passed in. This doesn't work for all cases, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useD-ComplexQuite challenging from either a design or technical perspective. Ask for help!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions