Merged
Conversation
Immutable components were introduced in Bevy via: bevyengine/bevy#16372 These components can only be changed via re-insertion. This allows users to enforce invariants through triggers and hooks. When porting to 0.16, I initially added a `Mutability = Mutable` constraint. To support immutable components, I replaced this constraint with the `MutWrite` trait. It is implemented for both `Mutable` and `Immutable` markers to select the appropriate write function. For `Immutable` components, this function always performs insertion.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## bevy-0.16-dev #468 +/- ##
=================================================
- Coverage 79.87% 79.86% -0.02%
=================================================
Files 52 52
Lines 2768 2776 +8
=================================================
+ Hits 2211 2217 +6
- Misses 557 559 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
UkoeHB
requested changes
Apr 22, 2025
| } | ||
|
|
||
| #[test] | ||
| fn immutable() { |
Collaborator
There was a problem hiding this comment.
Need test for re-inserting an immutable component with different value.
Co-authored-by: UkoeHB <37489173+UkoeHB@users.noreply.github.com>
UkoeHB
approved these changes
Apr 22, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Immutable components were introduced in Bevy via: bevyengine/bevy#16372
These components can only be changed via re-insertion. This allows users to enforce invariants through triggers and hooks.
When porting to 0.16, I initially added a
Mutability = Mutableconstraint. In this PR, to support immutable components, I replaced this constraint with theMutWritetrait. It is implemented for bothMutableandImmutablemarkers to select the appropriate write function. ForImmutablecomponents, this function always performs insertion.