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

Add into_ methods for EntityMut and EntityWorldMut that consume self. #12419

Merged
merged 1 commit into from
Mar 17, 2024

Conversation

jkb0o
Copy link
Contributor

@jkb0o jkb0o commented Mar 11, 2024

Objective

Provide component access to &'w T, Ref<'w, T>, Mut<'w, T>, Ptr<'w> and MutUntyped<'w> from EntityMut<'w>/EntityWorldMut<'w> with the world 'w lifetime instead of '_.

Fixes #12417

Solution

Add into_ prefixed methods for EntityMut<'w>/EntityWorldMut<'w> that consume self and returns component access with the world 'w lifetime unlike the get_ prefixed methods that takes &'a self and returns component access with 'a lifetime.

Methods implemented:

  • EntityMut::into_borrow
  • EntityMut::into_ref
  • EntityMut::into_mut
  • EntityMut::into_borrow_by_id
  • EntityMut::into_mut_by_id
  • EntityWorldMut::into_borrow
  • EntityWorldMut::into_ref
  • EntityWorldMut::into_mut
  • EntityWorldMut::into_borrow_by_id
  • EntityWorldMut::into_mut_by_id

@jkb0o

This comment was marked as resolved.

@jkb0o jkb0o force-pushed the pr/entity_world_mut_into_mut branch from ada5f60 to 0a90863 Compare March 11, 2024 11:28
@jkb0o

This comment was marked as resolved.

@jkb0o jkb0o force-pushed the pr/entity_world_mut_into_mut branch from 0a90863 to 6064efe Compare March 11, 2024 11:33
@jkb0o jkb0o changed the title Add grab method for EntityMut and EntityWorldMut that consume self. Add grab methods for EntityMut and EntityWorldMut that consume self. Mar 11, 2024
The into_ methods on the EntityMut/EntityWorldMut consumes self and returns
component access with the world lifetime unlike the get_ methods that takes
ref and retuns component acess with &'a self lifetime.

Methods implemented:
- EntityMut::into_borrow
- EntityMut::into_ref
- EntityMut::into_mut
- EntityMut::into_by_id
- EntityMut::into_mut_by_id
- EntityWorldMut::into_borrow
- EntityWorldMut::into_ref
- EntityWorldMut::into_mut
- EntityWorldMut::into_by_id
- EntityWorldMut::into_mut_by_id
@jkb0o jkb0o force-pushed the pr/entity_world_mut_into_mut branch from 6064efe to 7ca36fa Compare March 11, 2024 12:35
@pablo-lua
Copy link
Contributor

Looks like you changed the methods name, can you change the title to reflect those changes?

@jkb0o jkb0o changed the title Add grab methods for EntityMut and EntityWorldMut that consume self. Add inro_ methods for EntityMut and EntityWorldMut that consume self. Mar 11, 2024
@jkb0o jkb0o changed the title Add inro_ methods for EntityMut and EntityWorldMut that consume self. Add into_ methods for EntityMut and EntityWorldMut that consume self. Mar 11, 2024
@james7132 james7132 added A-ECS Entities, components, systems, and events C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Mar 11, 2024
@james7132 james7132 added this to the 0.14 milestone Mar 11, 2024
Copy link
Member

@james7132 james7132 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks for covering the untyped APIs too.

@james7132 james7132 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 Mar 11, 2024
@james7132 james7132 added this pull request to the merge queue Mar 17, 2024
Merged via the queue into bevyengine:main with commit 5d0ff60 Mar 17, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ECS Entities, components, systems, and events 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
None yet
Development

Successfully merging this pull request may close these issues.

Missing EntityWorldMut::into_mut(self)
3 participants