async_ecs/storage/
anti_storage.rs

1use hibitset::{BitSet, BitSetNot};
2
3use crate::{
4    entity::Index,
5    join::{Join, ParJoin},
6};
7
8use super::DistinctStorage;
9
10/// An inverted storage type, only useful to iterate entities
11/// that do not have a particular component type.
12pub struct AntiStorage<'a>(pub &'a BitSet);
13
14impl<'a> DistinctStorage for AntiStorage<'a> {}
15
16impl<'a> Join for AntiStorage<'a> {
17    type Mask = BitSetNot<&'a BitSet>;
18    type Type = ();
19    type Value = ();
20
21    unsafe fn open(self) -> (Self::Mask, ()) {
22        (BitSetNot(self.0), ())
23    }
24
25    unsafe fn get(_: &mut Self::Value, _: Index) {}
26}
27
28impl<'a> ParJoin for AntiStorage<'a> {}