Bevy settings support tuple structs and non-unit like enums#23812
Merged
alice-i-cecile merged 2 commits intobevyengine:mainfrom Apr 15, 2026
Merged
Conversation
viridia
approved these changes
Apr 15, 2026
Contributor
|
We should update the release note to include these follow-on PR numbers. |
alice-i-cecile
approved these changes
Apr 15, 2026
Member
IMO we shouldn't bother supporting unions. I have never seen these used for normal Rust things in a way that you might use in settings. |
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.
Objective
Implements part of #23302
For background on bevy settings see the initial PR:
#23034
Solution
As we invoke the serde toml serializer:
Single field tuple structs are serialized as single values:
Results in:
Multi-field tuple structs are serialized as arrays of values, with nested structs serialized as inline tables:
Results in:
Non-unit enums retain the "key" field with it defaulting the resources name, with it being serialized into the group table:
Results in:
The same multi-field tuple serialization occurs in enums:
Results in:
Enums variants with fields are serialised with field entries:
Results in:
Notes
[group_name.key_name]for non-unit like enums, its easy enough to not include the key for these types but i'll keep in for the sake of discussion.Testing
persisting_preferencesexample and cross referenced the toml output in the file.