1use super::*;
2
3pub trait Query {
4 type Fetch: for<'a> Fetch<'a> + Default;
5}
6
7pub type QueryOutput<'a, Q> = <<Q as Query>::Fetch as Fetch<'a>>::Output;
8
9impl<'a, T: Component> Query for &'a T {
10 type Fetch = FetchRead<T>;
11}
12
13impl<'a, T: Component> Query for &'a mut T {
14 type Fetch = FetchWrite<T>;
15}
16
17impl<Q: Query> Query for Option<Q> {
18 type Fetch = OptionFetch<Q::Fetch>;
19}
20
21impl<F: Filter + Default> Query for Is<F> {
22 type Fetch = FilterFetch<F>;
23}
24
25macro_rules! impl_for_tuple {
26 ($($name:ident),*) => {
27 #[allow(non_camel_case_types)]
28 #[allow(unused_variables)]
29 impl<$($name: Query),*> Query for ($($name,)*) {
30 type Fetch = ($($name::Fetch,)*);
31 }
32 };
33}
34
35impl_tuples!(impl_for_tuple);