-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Missing EntityWorldMut::into_mut(self) #12417
Comments
Might be good to add an equivalent functions for
The docs will likely need to clarify what the difference between these and |
@james7132 I'm not sure we need fn translation_ref<'w>(id: Entity, world: &'w mut World) -> Ref<'w, Vec3> {
world
.entity(id)
.get_ref::<Transform>()
.unwrap()
.map(|r| &r.translation)
} The problem only with mutable access. |
And I'm not sure what |
Ah right,
|
…#12419) # 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
What problem does this solve or what need does it fill?
For my plugin I'd like to have closures that takes
Entity
and&' mut World
and returnsMut<'w, T>
:This code won't compile:
It happens because
EntityWorldMut<'w>::get_mut(&mut self)
returnsMut
with lifetime of&mut self
instead of'w
.What solution would you like?
It would be nice to have some method on
EntityWorldMut
likeget_mut
but that consumes self and returnsMut<'w, T>
:It is possible to implement the translation function for now:
What alternative(s) have you considered?
I didn't find a way to bypass proper lifetime within my
transform
function without making changes to engine.The text was updated successfully, but these errors were encountered: