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

[Merged by Bors] - create mutable versions of TypeRegistry methods #4484

Closed
wants to merge 1 commit into from

Conversation

oddfacade
Copy link
Contributor

Objective

It is possible to get a mutable reference to a TypeRegistration using
TypeRegistry::get_mut. However, none of its other methods
(get_mut_with_name, get_type_data, iter, etc.) have mutable
versions.

Besides improving consistency, this change would facilitate use cases
which involve storing mutable state data in the TypeRegistry.

Solution

Provides a trivial wrapper around the mutable accessors that the
TypeRegistration already provides. Exactly mirrors the existing
immutable versions.

# Objective

It is possible to get a mutable reference to a `TypeRegistration` using
`TypeRegistry::get_mut`. However, none of its other methods
(`get_mut_with_name`, `get_type_data`, `iter`, etc.) have mutable
versions.

Besides improving consistency, this change would facilitate use cases
which involve storing mutable state data in the `TypeRegistry`.

## Solution

Provides a trivial wrapper around the mutable accessors that the
`TypeRegistration` already provides. Exactly mirrors the existing
immutable versions.
@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Apr 15, 2022
@alice-i-cecile alice-i-cecile added A-Reflection Runtime information about types C-Usability A targeted quality-of-life change that makes Bevy easier to use and removed S-Needs-Triage This issue needs to be labelled labels Apr 16, 2022
Copy link
Member

@MrGVSV MrGVSV left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Side Note: I wish there was a better name than get_with_short_name and get_with_short_name_mut, but it is what it is I suppose 😅

@bjorn3
Copy link
Contributor

bjorn3 commented Apr 17, 2022

If a type changes isn't it just a different type that should get a different TypeRegistration?

@oddfacade
Copy link
Contributor Author

If a type changes isn't it just a different type that should get a different TypeRegistration?

the type isn't changing; the data registered via the type is changing. at the moment, this functionality is mainly used to store method tables keyed by type. mutability in this context can loosely be thought of as "class variables" in an OOP paradigm.

@alice-i-cecile alice-i-cecile 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 Apr 18, 2022
@MrGVSV
Copy link
Member

MrGVSV commented Apr 23, 2022

Note that if #4567 is merged, then the added get_type_data_mut will need to be removed.

@mockersf
Copy link
Member

bors try

bors bot added a commit that referenced this pull request Apr 23, 2022
@bors
Copy link
Contributor

bors bot commented Apr 23, 2022

try

Build failed:

@alice-i-cecile
Copy link
Member

bors r+

bors bot pushed a commit that referenced this pull request May 9, 2022
# Objective

It is possible to get a mutable reference to a `TypeRegistration` using
`TypeRegistry::get_mut`. However, none of its other methods
(`get_mut_with_name`, `get_type_data`, `iter`, etc.) have mutable
versions.

Besides improving consistency, this change would facilitate use cases
which involve storing mutable state data in the `TypeRegistry`.

## Solution

Provides a trivial wrapper around the mutable accessors that the
`TypeRegistration` already provides. Exactly mirrors the existing
immutable versions.
@bors bors bot changed the title create mutable versions of TypeRegistry methods [Merged by Bors] - create mutable versions of TypeRegistry methods May 9, 2022
@bors bors bot closed this May 9, 2022
robtfm pushed a commit to robtfm/bevy that referenced this pull request May 10, 2022
# Objective

It is possible to get a mutable reference to a `TypeRegistration` using
`TypeRegistry::get_mut`. However, none of its other methods
(`get_mut_with_name`, `get_type_data`, `iter`, etc.) have mutable
versions.

Besides improving consistency, this change would facilitate use cases
which involve storing mutable state data in the `TypeRegistry`.

## Solution

Provides a trivial wrapper around the mutable accessors that the
`TypeRegistration` already provides. Exactly mirrors the existing
immutable versions.
exjam pushed a commit to exjam/bevy that referenced this pull request May 22, 2022
# Objective

It is possible to get a mutable reference to a `TypeRegistration` using
`TypeRegistry::get_mut`. However, none of its other methods
(`get_mut_with_name`, `get_type_data`, `iter`, etc.) have mutable
versions.

Besides improving consistency, this change would facilitate use cases
which involve storing mutable state data in the `TypeRegistry`.

## Solution

Provides a trivial wrapper around the mutable accessors that the
`TypeRegistration` already provides. Exactly mirrors the existing
immutable versions.
@oddfacade oddfacade deleted the type_registry_iter_mut branch September 30, 2022 04:50
ItsDoot pushed a commit to ItsDoot/bevy that referenced this pull request Feb 1, 2023
# Objective

It is possible to get a mutable reference to a `TypeRegistration` using
`TypeRegistry::get_mut`. However, none of its other methods
(`get_mut_with_name`, `get_type_data`, `iter`, etc.) have mutable
versions.

Besides improving consistency, this change would facilitate use cases
which involve storing mutable state data in the `TypeRegistry`.

## Solution

Provides a trivial wrapper around the mutable accessors that the
`TypeRegistration` already provides. Exactly mirrors the existing
immutable versions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Reflection Runtime information about types C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants