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
44
45
46
47
48
49
50
51
52
53
54
55
use super::{DynamicFilter, FilterResult, GroupMatcher, LayoutFilter};
use crate::internals::{query::view::Fetch, storage::component::ComponentTypeId, world::WorldId};

/// A filter which always defers.
#[derive(Debug, Clone, Default)]
pub struct Passthrough;

impl GroupMatcher for Passthrough {
    fn can_match_group() -> bool {
        true
    }
    fn group_components() -> Vec<ComponentTypeId> {
        vec![]
    }
}

impl LayoutFilter for Passthrough {
    fn matches_layout(&self, _: &[ComponentTypeId]) -> FilterResult {
        FilterResult::Defer
    }
}

impl DynamicFilter for Passthrough {
    fn prepare(&mut self, _: WorldId) {}
    fn matches_archetype<F: Fetch>(&mut self, _: &F) -> FilterResult {
        FilterResult::Defer
    }
}

impl std::ops::Not for Passthrough {
    type Output = Passthrough;

    #[inline]
    fn not(self) -> Self::Output {
        self
    }
}

impl<Rhs> std::ops::BitAnd<Rhs> for Passthrough {
    type Output = Rhs;

    #[inline]
    fn bitand(self, rhs: Rhs) -> Self::Output {
        rhs
    }
}

impl<Rhs> std::ops::BitOr<Rhs> for Passthrough {
    type Output = Rhs;

    #[inline]
    fn bitor(self, rhs: Rhs) -> Self::Output {
        rhs
    }
}