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

implement Deref for State<S> #8668

Merged
merged 1 commit into from May 25, 2023
Merged

implement Deref for State<S> #8668

merged 1 commit into from May 25, 2023

Conversation

atornity
Copy link
Contributor

@atornity atornity commented May 24, 2023

Objective

  • Allow for directly call methods on states without first calling state.get().my_method()

Solution

  • Implement Deref for State<S> with Target = S

Changelog

changes:

  • Implemented Deref for State<S> with Target = S

I did not implement DerefMut because states hold no data and should only be changed via NextState::set()

@atornity atornity changed the title implement Deref for State<S> implement Deref for State<S> May 24, 2023
@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 May 24, 2023
@alice-i-cecile
Copy link
Member

alice-i-cecile commented May 24, 2023

I like this. I think it's the right call to skip DerefMut because of the fact that states should generally be set via NextState<S>, but it's nice to explain it for posterity.

@james7132 james7132 added this pull request to the merge queue May 25, 2023
@james7132 james7132 removed this pull request from the merge queue due to a manual request May 25, 2023
@james7132
Copy link
Member

Can you please add a Changelog section to the PR description? This would help our releasing process significantly.

@james7132 james7132 added this pull request to the merge queue May 25, 2023
@atornity
Copy link
Contributor Author

Can you please add a Changelog section to the PR description? This would help our releasing process significantly.

this ok?

Merged via the queue into bevyengine:main with commit bc9144b May 25, 2023
23 checks passed
@alice-i-cecile
Copy link
Member

Yep changelog looks good.

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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants