1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use super::{
boolean::{BooleanQuery, OrOp},
read::Read,
write::Write,
IntoQuery,
};
marker_type! {
/// A query adaptor parameterized by a tuple of queries.
/// Yields a tuple of items from each query wrapped in `Option`.
/// Yields `None` for queries that do not match the entity.
/// Skips if no queries match the entity.
pub struct AnyOf<T>;
}
macro_rules! any_of {
() => { /* Don't implement for empty tuple */ };
($($a:ident)+) => {
impl<$($a),+> IntoQuery for AnyOf<($(&$a,)+)>
where
$($a: Sync + 'static,)+
{
type Query = BooleanQuery<($(Read<$a>,)+), OrOp>;
fn into_query(self) -> Self::Query {
BooleanQuery::from_tuple(($(Read::<$a>,)*))
}
}
impl<$($a),+> IntoQuery for AnyOf<($(&mut $a,)+)>
where
$($a: Send + 'static,)+
{
type Query = BooleanQuery<($(Write<$a>,)+), OrOp>;
fn into_query(self) -> Self::Query {
BooleanQuery::from_tuple(($(Write::<$a>,)*))
}
}
};
}
for_tuple!(any_of);