-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
What problem does this solve or what need does it fill?
Right now, if you want to guarantee true type-level invariants on some of your data, you have to stuff it all together in a container type, and then provide public functions that do the relevant mutation while upholding the required invariants.
Splitting up such a monolithic container into smaller types allows more concurrent read access to the data, but also risks mis-using mutable access for these types.
-@JeanMertz on Discord
What solution would you like?
@TheRawMeatball thinks this could be done with derives for components, allowing you to export immutable-only variants of components for use elsewhere in your game.
What alternative(s) have you considered?
Use pub
to control mutable access. Unfortunately, this restricts both immutable and mutable access in the same way, preventing us from reading the component elsewhere. This is an important distinction, since read-only access is much less likely to create horrifying spaghetti code.
Additional context
None.