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

Return a boolean from set_if_neq #9801

Merged
merged 1 commit into from
Sep 14, 2023
Merged

Conversation

JoJoJet
Copy link
Member

@JoJoJet JoJoJet commented Sep 14, 2023

Objective

When using set_if_neq, sometimes you'd like to know if the new value was different from the old value so that you can perform some additional branching.

Solution

Return a bool from this function, which indicates whether or not the value was overwritten.


Changelog

  • DetectChangesMut::set_if_neq now returns a boolean indicating whether or not the value was changed.

Migration Guide

The trait method DetectChangesMut::set_if_neq now returns a boolean value indicating whether or not the value was changed. If you were implementing this function manually, you must now return true if the value was overwritten and false if the value was not.

@JoJoJet JoJoJet added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide labels Sep 14, 2023
@alice-i-cecile
Copy link
Member

Good call, I should have done this originally.

@hymm hymm 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 14, 2023
@mockersf mockersf added this pull request to the merge queue Sep 14, 2023
Merged via the queue into bevyengine:main with commit 90b741d Sep 14, 2023
26 checks passed
@JoJoJet JoJoJet deleted the return-set-if-neq branch September 14, 2023 02:18
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

When using `set_if_neq`, sometimes you'd like to know if the new value
was different from the old value so that you can perform some additional
branching.

## Solution

Return a bool from this function, which indicates whether or not the
value was overwritten.

---

## Changelog

* `DetectChangesMut::set_if_neq` now returns a boolean indicating
whether or not the value was changed.

## Migration Guide

The trait method `DetectChangesMut::set_if_neq` now returns a boolean
value indicating whether or not the value was changed. If you were
implementing this function manually, you must now return `true` if the
value was overwritten and `false` if the value was not.
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 targeted quality-of-life change that makes Bevy easier to use M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide 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