From e7719bf245249fe51d2897dd54bb93986096d230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucas=20Jen=C3=9F?= Date: Tue, 1 Nov 2022 03:15:34 +0000 Subject: [PATCH] Mention world_query(ignore) attribute for WorldQuery derivation (#6309) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Objective Add documentation `#[world_query(ignore)]`. Fixes #6283. --- I've only described it's behavior so far (which appears to be the same as with `system_param`). Is there another use-case for this besides with `PhantomData`? I could only find a single usage of this construct on GitHub, which is [here](https://github.com/tqwewe/bevy-editor-2/blob/ffcb816927a1bbdcf1cb0136ce47864e5040f9fb/bevy/examples/ecs/custom_query_param.rs#L102). I was also wondering if it would make sense to add a usage example to the `custom_query_example`? 🤔 That's why it's currently still in there. Co-authored-by: Lucas Jenß <243719+x3ro@users.noreply.github.com> --- crates/bevy_ecs/src/query/fetch.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/bevy_ecs/src/query/fetch.rs b/crates/bevy_ecs/src/query/fetch.rs index 52886817e20e0..b80000de7be0e 100644 --- a/crates/bevy_ecs/src/query/fetch.rs +++ b/crates/bevy_ecs/src/query/fetch.rs @@ -55,7 +55,13 @@ use std::{cell::UnsafeCell, marker::PhantomData}; /// - Methods can be implemented for the query items. /// - There is no hardcoded limit on the number of elements. /// -/// This trait can only be derived if each field of the struct also implements `WorldQuery`. +/// This trait can only be derived if each field either +/// +/// * also implements `WorldQuery`, or +/// * is marked with `#[world_query(ignore)]`. Fields decorated with this attribute +/// must implement [`Default`] and will be initialized to the default value as defined +/// by the trait. +/// /// The derive macro only supports regular structs (structs with named fields). /// /// ```