1use crate::node::NodeTrait;
2use crate::target::RefSet;
3use std::array::from_fn;
4
5unsafe impl<'gc, T: RefSet<'gc>, const N: usize> RefSet<'gc> for [T; N] {
6 #[inline(always)]
7 unsafe fn build() -> Self {
8 from_fn(|_| T::build())
9 }
10
11 #[inline(always)]
12 unsafe fn collect(&self, stack: &mut Vec<&dyn NodeTrait<'gc>>) {
13 for i in self {
14 i.collect(stack);
15 }
16 }
17}
18
19unsafe impl<'gc> RefSet<'gc> for () {
20 #[inline(always)]
21 unsafe fn build() -> Self {}
22
23 #[inline(always)]
24 unsafe fn collect(&self, _stack: &mut Vec<&dyn NodeTrait<'gc>>) {}
25}
26
27macro_rules! impl_ref_set_for_tuple {
28 ($($T:ident:$i:tt),*) => {
29 unsafe impl<'gc, $($T: RefSet<'gc>),*> RefSet<'gc> for ($($T,)*) {
30 #[inline(always)]
31 unsafe fn build() -> Self {
32 ($($T::build(),)*)
33 }
34
35 #[inline(always)]
36 unsafe fn collect(&self, stack: &mut Vec<&dyn NodeTrait<'gc>>) {
37 $(self.$i.collect(stack);)*
38 }
39 }
40 };
41}
42
43impl_ref_set_for_tuple!(A:0);
44impl_ref_set_for_tuple!(A:0, B:1);
45impl_ref_set_for_tuple!(A:0, B:1, C:2);
46impl_ref_set_for_tuple!(A:0, B:1, C:2, D:3);
47impl_ref_set_for_tuple!(A:0, B:1, C:2, D:3, E:4);
48impl_ref_set_for_tuple!(A:0, B:1, C:2, D:3, E:4, F:5);
49impl_ref_set_for_tuple!(A:0, B:1, C:2, D:3, E:4, F:5, G:6);
50impl_ref_set_for_tuple!(A:0, B:1, C:2, D:3, E:4, F:5, G:6, H:7);
51impl_ref_set_for_tuple!(A:0, B:1, C:2, D:3, E:4, F:5, G:6, H:7, I:8);
52impl_ref_set_for_tuple!(A:0, B:1, C:2, D:3, E:4, F:5, G:6, H:7, I:8, J:9);
53impl_ref_set_for_tuple!(A:0, B:1, C:2, D:3, E:4, F:5, G:6, H:7, I:8, J:9, K:10);
54impl_ref_set_for_tuple!(A:0, B:1, C:2, D:3, E:4, F:5, G:6, H:7, I:8, J:9, K:10, L:11);