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

feat: make World only ever require &self. #270

Merged
merged 1 commit into from
Dec 1, 2023

Conversation

zicklag
Copy link
Member

@zicklag zicklag commented Nov 30, 2023

This is wide but relatively shallow update that makes World only ever require &self, allowing us to remove the system initialization stage that was necessary to have &mut World access for initializing resources and components.

The main change was to allow Resources to have resources added to it with only a &self reference by using a once_map internally. This meant that all resource cells now become Option<SchemaBox> on the inside. This conceptually means that cells for reasources are lazily initialized and always considered to be present, but they may or may not actually contain a resource value.

This is wide but relatively shallow update that makes `World` only ever
require `&self`, allowing us to remove the system initialization stage
that was necessary to have `&mut World` access for initializing resources
and components.

The main change was to allow `Resources` to have resources added to it
with only a `&self` reference by using a `once_map` internally. This
meant that all resource cells now become `Option<SchemaBox>` on the
inside. This conceptually means that cells for reasources are lazily
initialized and always considered to be present, but they may or may not
actually contain a resource value.
@zicklag zicklag added this pull request to the merge queue Dec 1, 2023
Merged via the queue into fishfolk:main with commit 019a592 Dec 1, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant