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
56
57
58
59
60
61
62
63
64
65
66
67
68
use super::AbstractMut;
use crate::entity_id::EntityId;
use crate::or::{OneOfTwo, Or};

impl<T: AbstractMut, U: AbstractMut> AbstractMut for Or<(T, U)>
where
    <U as AbstractMut>::Index: Into<usize> + Clone,
{
    type Out = OneOfTwo<T::Out, U::Out>;
    type Index = OneOfTwo<T::Index, U::Index>;

    #[inline]
    unsafe fn get_data(&self, _: usize) -> Self::Out {
        unreachable!()
    }
    #[inline]
    unsafe fn get_datas(&self, index: Self::Index) -> Self::Out {
        match index {
            OneOfTwo::One(index) => OneOfTwo::One((self.0).0.get_datas(index)),
            OneOfTwo::Two(index) => OneOfTwo::Two((self.0).1.get_datas(index)),
        }
    }
    #[inline]
    fn indices_of(&self, entity: EntityId, index: usize, mask: u16) -> Option<Self::Index> {
        if index < (self.0).0.len() {
            let index = (self.0).0.indices_of(entity, index, mask)?;
            Some(OneOfTwo::One(index))
        } else {
            let index = (self.0).1.indices_of(entity, index, mask)?;
            if (self.0)
                .0
                .indices_of(entity, index.clone().into(), mask)
                .is_some()
            {
                return None;
            }
            Some(OneOfTwo::Two(index))
        }
    }
    #[inline]
    #[allow(clippy::manual_map)]
    fn indices_of_passenger(
        &self,
        entity: EntityId,
        index: usize,
        mask: u16,
    ) -> Option<Self::Index> {
        if let Some(index) = (self.0).0.indices_of(entity, index, mask) {
            Some(OneOfTwo::One(index))
        } else if let Some(index) = (self.0).1.indices_of(entity, index, mask) {
            Some(OneOfTwo::Two(index))
        } else {
            None
        }
    }
    #[inline]
    unsafe fn indices_of_unchecked(&self, _: EntityId, _: usize, _: u16) -> Self::Index {
        unreachable!()
    }
    #[inline]
    unsafe fn get_id(&self, _: usize) -> EntityId {
        unreachable!()
    }
    #[inline]
    fn len(&self) -> usize {
        0
    }
}