Skip to content

How to take back the ownership of a component from the world? #13116

Answered by SkiFire13
navneetankur asked this question in Q&A
Discussion options

You must be logged in to vote

You can use world.entity_mut(your_entity_id) to get a EntityWorldMut and then call .take::<YourComponentType>() on it to get ownership of the component.

without Drop-ing.

Please be careful with that since not dropping some value probably means leaking memory, which in the long run is going to make your program run out of memory and crash.

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
2 replies
@navneetankur
Comment options

@SkiFire13
Comment options

Answer selected by navneetankur
Comment options

You must be logged in to vote
3 replies
@navneetankur
Comment options

@alice-i-cecile
Comment options

@navneetankur
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants