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

Make QueryState::as_nop pub(crate) #12752

Closed
ItsDoot opened this issue Mar 27, 2024 · 0 comments · Fixed by #12776
Closed

Make QueryState::as_nop pub(crate) #12752

ItsDoot opened this issue Mar 27, 2024 · 0 comments · Fixed by #12776
Labels
A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy

Comments

@ItsDoot
Copy link
Contributor

ItsDoot commented Mar 27, 2024

Rationale

QueryState::as_nop is currently only used in two places:

Looking at the method's signature:

pub fn as_nop(&self) -> &QueryState<NopWorldQuery<D>, F>;

It's not really usable by consumers because it returns a non-mut reference, while a majority of QueryState methods require &mut self.

As for the NopWorldQuery higher-order WorldQuery, there are outside users of that, so it should be kept public.

What solution would you like?

Make as_nop pub(crate):

pub(crate) fn as_nop(&self) -> &QueryState<NopWorldQuery<D>, F>;

What alternative(s) have you considered?

Leave it public.

Additional context

Originally brought up on discord:

Ryos — Today at 2:05 PM
Speaking of seemingly weird oversights, QueryState::as_nop renders almost all of QueryState's API unusable, as it returns a &QueryState, while all of QueryState's non-manual methods take &mut self

@ItsDoot ItsDoot added A-ECS Entities, components, systems, and events C-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy labels Mar 27, 2024
@ItsDoot ItsDoot changed the title Consider making QueryState::as_nop pub(crate) Make QueryState::as_nop pub(crate) Mar 27, 2024
github-merge-queue bot pushed a commit that referenced this issue Mar 29, 2024
…ate) (#12776)

# Objective
Fixes #12752. Fixes #12750. Document the runtime complexity of all of
the `O(1)` operations on the individual APIs.

## Solution

  * Mirror `Query::contains` onto `QueryState::contains`
  * Make `QueryState::as_nop` pub(crate)
  * Make `NopWorldQuery` pub(crate)
  * Document all of the O(1) operations on Query and QueryState.
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-Code-Quality A section of code that is hard to understand or change D-Trivial Nice and easy! A great choice to get started with Bevy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant