Skip to content

Conversation

@ecoskey
Copy link
Contributor

@ecoskey ecoskey commented Dec 4, 2025

Objective

Allow reborrowing for QueryData types. The end goal here is to work towards a fast System::run_iter api, avoiding the overhead of get_param with each iteration. Funnily enough the only system param that actually needs this is Single, but it seems worthwhile to have anyways

Next steps:

  1. ReborrowSystemParam
  2. SystemIter

Solution

  • Add ReborrowQueryData, an optional subtrait (though almost all QueryData types should implement this in practice)
/// A [`QueryData`] that's able to be reborrowed, converting a reference into
/// an owned struct with a shorter lifetime.
pub trait ReborrowQueryData: QueryData {
    /// Returns a `QueryData` item with a smaller lifetime.
    fn reborrow<'wlong: 'short, 'slong: 'short, 'short>(
        item: &'short mut Self::Item<'wlong, 'slong>,
    ) -> Self::Item<'short, 'short>;
}

@ecoskey ecoskey added A-ECS Entities, components, systems, and events D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged C-Feature A new feature, making something new possible S-Needs-Review Needs reviewer attention (from anyone!) to move forward and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Dec 4, 2025
@ecoskey ecoskey force-pushed the feature/query_reborrow branch from 38cc1a5 to 6becb1e Compare December 5, 2025 20:49
@ecoskey ecoskey force-pushed the feature/query_reborrow branch from 6becb1e to 6f0ab87 Compare December 6, 2025 21:52
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 D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Needs-Review Needs reviewer attention (from anyone!) to move forward

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant