Skip to content

Commit

Permalink
Mention world_query(ignore) attribute for WorldQuery derivation
Browse files Browse the repository at this point in the history
Fixes #6283
  • Loading branch information
Lucas committed Oct 19, 2022
1 parent abbc0cf commit 87cdfbe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/bevy_ecs/src/query/fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ 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
/// will be created with the default value upon realisation.
///
/// The derive macro only supports regular structs (structs with named fields).
///
/// ```
Expand Down
2 changes: 2 additions & 0 deletions examples/ecs/custom_query_param.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ struct CustomQuery<T: Component + Debug, P: Component + Debug> {
optional_tuple: Option<(NestedQuery, &'static mut ComponentZ)>,
generic: GenericQuery<T, P>,
empty: EmptyQuery,
#[world_query(ignore)]
foo: String,
}

// This is a valid query as well, which would iterate over every entity.
Expand Down

0 comments on commit 87cdfbe

Please sign in to comment.