pub trait Kind:
Sized
+ 'static
+ Send
+ Sync {
type Filter: QueryFilter;
// Provided method
fn debug_name() -> String { ... }
}Expand description
A type which represents the kind of an Entity.
An entity is of kind T if it matches Query<Entity, <T as Kind>::Filter>.
By default, an entity with a Component of type T is also of kind T.
§Examples
#[derive(Component)]
struct Apple;
#[derive(Component)]
struct Orange;
struct Fruit;
impl Kind for Fruit {
type Filter = Or<(With<Apple>, With<Orange>)>;
}
fn fruits(query: Query<Instance<Fruit>>) {
for fruit in query.iter() {
println!("{fruit:?} is a fruit!");
}
}
Required Associated Types§
Sourcetype Filter: QueryFilter
type Filter: QueryFilter
The QueryFilter which defines this kind.
Provided Methods§
Sourcefn debug_name() -> String
fn debug_name() -> String
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.