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

derive(Query) doesn't support query transformers #335

Open
Ralith opened this issue Aug 28, 2023 · 0 comments
Open

derive(Query) doesn't support query transformers #335

Ralith opened this issue Aug 28, 2023 · 0 comments

Comments

@Ralith
Copy link
Owner

Ralith commented Aug 28, 2023

Most hecs queries yield exactly their Query::Item with a dummy 'static lifetime. The derive(Query) macro takes advantage of this to make both the query type and its item literally the same struct. This fails for structs that contain e.g. With/Without, which transform query types without modifying the Query::Item type; e.g. With<&i32, &bool> has Item type &i32, but is a ZST.

The macro could be modified to generate a separate Item struct where each field's type is the source query's field's Item type. This might be confusing in cases where it's not required, although I suspect few users are directly naming query item types often. The macro could potentially support both modes of operation, but that might increase confusion, and could not be done automatically in any case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant