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 panicking helpers for getting components from Query #9659

Merged
merged 2 commits into from
Sep 4, 2023

Conversation

Shatur
Copy link
Contributor

@Shatur Shatur commented Aug 31, 2023

Objective

Solution

  • Add these functions.

Changelog

Added

  • Query::component and Query::component_mut to get specific component from query and panic on error.

@alice-i-cecile alice-i-cecile added A-ECS Entities, components, systems, and events C-Usability A simple quality-of-life change that makes Bevy easier to use labels Aug 31, 2023
Copy link
Member

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "See also" section of the docs should point to the non-panicking equivalents, and vice versa :)

@Shatur
Copy link
Contributor Author

Shatur commented Aug 31, 2023

The "See also" section of the docs should point to the non-panicking equivalents, and vice versa :)

Currently we points from mut functions to non-mut equivalents. I can add pointing to non-panicking equivalents, but it will be 2 additional functions (mut and non-mut one). So should I point to 3 other functions?
Or should I only cross-reference panicking and non-panicking equivalents?
Please, advice :)

@alice-i-cecile
Copy link
Member

I would point to the adjacent functions in the panicking/mutability grid :) So each should reference two other methods.

@Shatur
Copy link
Contributor Author

Shatur commented Sep 2, 2023

@alice-i-cecile makes sense, done!

@alice-i-cecile
Copy link
Member

@Shatur, thinking about this a bit more, this should also exist on QueryState, and we should call the corresponding method from Query.

@Shatur
Copy link
Contributor Author

Shatur commented Sep 3, 2023

@alice-i-cecile hm... I don't see get_component in QueryState. Should I open a separate issue to add them or add (get_)component(_mut) here?

@alice-i-cecile
Copy link
Member

Separate issue to add them then please :)

@Shatur
Copy link
Contributor Author

Shatur commented Sep 3, 2023

@alice-i-cecile done: #9683

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Sep 3, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Sep 4, 2023
Merged via the queue into bevyengine:main with commit 9309d89 Sep 4, 2023
22 checks passed
@Shatur Shatur deleted the component-panic branch September 4, 2023 22:56
@cart cart mentioned this pull request Oct 13, 2023
43 tasks
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
…#9659)

# Objective

- Currently we don't have panicking alternative for getting components
from `Query` like for resources. Partially addresses bevyengine#9443.

## Solution

- Add these functions.

---

## Changelog

### Added

- `Query::component` and `Query::component_mut` to get specific
component from query and panic on error.
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-Usability A simple quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants