Skip to content

Add World::query_scope API #4157

@alice-i-cecile

Description

@alice-i-cecile

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

World::resource_scope is very useful for complex access patterns in exclusive systems.
However, it doesn't work with queries.

What solution would you like?

Add `fn query_scope(|q: Query<Q: WorldQuery, F: WorldQuery + FilterFetch>, world: &mut World |{}).

This temporarily removes all matching entities from the World, splitting the borrow.

What alternative(s) have you considered?

Use #4090 or SystemState instead. This won't cover all use cases: there are some things that can only be done with a &mut World.

Expand WorldCell to support queries, per #1555. This is substantially more error prone and slower, as the borrow-checking is done at runtime instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsC-FeatureA new feature, making something new possibleC-UsabilityA targeted quality-of-life change that makes Bevy easier to use

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions