Repository navigation
Conversation
Owner
This precludes abstracting over another query type. For example, see the queries |
Author
|
Updated in ec466d6 to remove all implicit
Verified locally: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #359.
#[derive(Query)]previously rejected any struct or enum with generic parameters beyond its single lifetime parameter (queries must have one generic parameter: a lifetime).Summary
Allows
#[derive(Query)]structs and enums to declare generic type and const parameters (including bounds, default arguments, andwhereclauses) alongside the required single query lifetime parameter:whereclauses onimpl Query, adding no implicit: ::hecs::Componentbounds so derived queries can abstract over arbitraryQuerytypes (includingOr,With, andWithout).FetchandStatestructs/enums over per-field fetch/state type parameters (__F0, .../__S0, ...) for fields whose types reference non-lifetime generic parameters, while keeping non-generic fields concrete insideFetch/State(preserving private field types onpubqueries withoutE0446and avoidingFetch: 'staticbounds on user type parameters).Clonefor the generatedFetchtype and manualCopy/Clonefor the generatedStatetype instead of#[derive(Clone, Copy)], so generic queries work with component types that do not implementCloneorCopy, and avoids shadowing when the input query lifetime is named'q.::core::panic!in enum query generation so enum queries without empty variants compile under#![no_implicit_prelude].Testing
cargo test -p hecs --all-featurespasses (46 unit tests, 11trybuildtests, 71 integration tests, 36 doctests, includingderived_query_abstracting_over_querywithOr,With, andWithout).cargo test -p hecs --no-default-featuresandcargo check -p test-no-std-macrospass.cargo fmt --all -- --check,cargo clippy --all-features --all-targets -- -D warnings, andRUSTDOCFLAGS="-Dwarnings" cargo doc --no-deps --all-featurespass.AI was used to write this code.