Closed rosenjcb closed 4 years ago
Is this addressable? I'm hoping this issue won't go stale.
this works afaict: (&mut foo_components).maybe()
@Imberflur someone just shared that with me the other day. It indeed does work. Thank you. I'll close this issue now.
Description
Sometimes there's a maybe component in your system. There is a syntax to handle this e.g:
However, the contents of
foo_component
will beOption<&Foo>
. Sometimes you can do aderef_mut
but this requires the component to implement theDerefMut
trait (and this will either be a clone or a transfer of ownership). The only way around this I found is to passEntitiesRes
into the system and grab the optional component from there. E.g.:Motivation
There should be an easier way to fetch the mutable entity from a
MaybeJoin
. The way I do it works but it breaks the convention thatspecs
prefers you to follow (i.e. iteration through the joins of one or many components).Drawbacks
None?
Unresolved questions
Maybe I just don't understand the right way to do it. If so, please correct me.