#[derive(Query)]Available on crate feature
macros only.Expand description
Implement Query for a struct or enum.
Queries can be passed to the type parameter of World::query. They must have exactly
one lifetime parameter, and all of their fields must be queries (e.g. references) using that
lifetime.
For enum queries, the result will always be the first variant that matches the entity. Unit variants and variants without any fields will always match an entity.
ยงExample
#[derive(Query, Debug, PartialEq)]
struct Foo<'a> {
x: &'a i32,
y: &'a mut bool,
}
let mut world = World::new();
let e = world.spawn((42, false));
assert_eq!(
world.query_one_mut::<Foo>(e).unwrap(),
Foo {
x: &42,
y: &mut false
}
);