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
|
use super::Entity;
use super::component::{Component, ComponentStorage};
pub trait ComponentBundle<W> {
fn insert(self, world: &mut W, entity: Entity);
}
macro_rules! impl_bundle_tuple {
($($T:ident),+) => {
impl<W, $($T),+> ComponentBundle<W> for ($($T,)+)
where
$(
$T: Component,
W: ComponentStorage<$T>,
)+
{
#[allow(non_snake_case)]
fn insert(self, world: &mut W, entity: Entity) {
let ($($T,)+) = self;
$(
world.insert(entity, $T);
)+
}
}
};
}
impl_bundle_tuple!(A);
impl_bundle_tuple!(A, B);
impl_bundle_tuple!(A, B, C);
impl_bundle_tuple!(A, B, C, D);
impl_bundle_tuple!(A, B, C, D, E);
impl_bundle_tuple!(A, B, C, D, E, F);
|