Trait moonshine_kind::Kind

source ·
pub trait Kind: 'static + Send + Sized + 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§

Provided Methods§

source

fn debug_name() -> String

Returns the debug name of this kind.

By default, this is the short type name (without path) of this kind.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Kind for Any

§

type Filter = ()

source§

impl<T: Component> Kind for T

§

type Filter = With<T>