-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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 support for 'or' in ECS querying #218
Conversation
This is definitely welcome functionality. At first glance this feels like the right approach, but I'll need a bit of time to think this one over. Thanks! |
This could also be called |
Yeah I prefer This is good to go as soon as:
|
…nged queries (using should_skip method).
3cd4a42
to
49719d4
Compare
@cart I renamed Either to Or and completed the test to confirm that |
Yeah macros (or a bunch of manual implementations) are the only way to accomplish this. They would require Or to be the type and then we would impl the relevant traits for each Or<(&A, &B)>, Or<(&A, &B, &C)>, etc via macro. Given that nesting should already work (ex: For now, maybe just add a test that proves that nesting works and then we can merge this? |
I had fun implementing the aforementioned macros in this PR #358 ! I added the test for nested queries; the destructuring of nested tuples is a bit of a mouthful, but it works as intended 👍 |
Nice! that was fast. Now i guess the only question is which one we pick. I think the tuple actually reads better, but Or<&A, &B> is simpler and has parity with rust or semantics. I'll give this a little bit of thought and let you know what i think. I'm also curious what your thoughts are! |
To me the clarity cost of the nested approach is exponential in the tuple size, so if we have to consider large "Mutated queries", the tuple approach may be the way to go. I agree with you on the cons, though |
Yeah I think the tuple approach is much more legible. Lets roll with that. |
Closing in favor of #358 |
Add Either query for a to do a logical or on a pair of Mutated or Changed queries (using should_skip method).
#162
One problem with this solution is that Query<Either<Mutated, Mutated>, C> yields a hierarchical tuple ((a,b), c) and not (a, b, c)