bevy_either/lib.rs
1//! # `bevy-either`
2//!
3//! This library provides [world queries] over other [world queries], allowing only one of multiple
4//! to be satisfied and returning the query items.
5//!
6//! ## [`Either<T, U>`](Either)
7//!
8//! Given two [world queries] `T` and `U`, `Either<T, U>` provides a [world query] that contains
9//! either the [`T`'s item](Either::Left) or the [`U`'s item](Either::Right). If both `T` and `U`
10//! successfully match an entity, then only [`T`'s item](Either::Left) is given, e.g. there isn't a
11//! "both" variant.
12//!
13//! ## [`EitherBoth<T, U>`](EitherBoth)
14//!
15//! Similarly to [`Either<T, U>`](Either), [`EitherBoth<T, U>`](EitherBoth) does allow one to match
16//! over [`T`'s item](EitherBoth::Left) or [`U`'s item](EitherBoth::Right). What sets it apart is
17//! the [`Both(t, u)`](EitherBoth::Both) variant, allowing both `T`'s and `U`'s items to be
18//! provided, given that they do both match.
19//!
20//! ## [`either_many!`](either_many)
21//!
22//! This macro creates a new [world query] enum with a new variant for each of its possible matched
23//! [world queries]. There isn't a "both"/"multiple" variant and the priority is always given to the
24//! first declared variant when multiple matches occur. This lets you create [world queries] similar
25//! to [`Either`], matching over one of the variant [world queries] with some priority order.
26//!
27//! ### `readonly`
28//!
29//! When using [`either_many!`](either_many), you can put `readonly` before the name of the new
30//! [query](WorldQuery). This will make the resulting type's [fetcher](Fetch)
31//! [read only](ReadOnlyFetch). The type is [read only](ReadOnlyFetch) if and only if all of its
32//! variants are [read only](ReadOnlyFetch), and this is an invariant *you* must uphold.
33//!
34//! [world query]: WorldQuery
35//! [world queries]: WorldQuery
36
37#![no_std]
38
39use bevy::prelude::*;
40use bevy::ecs::{storage::*, component::*, archetype::*, query::*};
41
42mod either_both;
43mod either;
44mod either_many;
45
46pub use either_both::EitherBoth;
47pub use either::Either;
48
49pub mod exports {
50 pub use paste::paste;
51}