17
17
18
18
use bevy:: utils:: all_tuples;
19
19
20
+ use itertools:: Itertools ;
20
21
use smallvec:: SmallVec ;
21
22
22
23
use crate :: {
@@ -36,7 +37,7 @@ pub trait Unzippable: Sized {
36
37
}
37
38
38
39
macro_rules! impl_unzippable_for_tuple {
39
- ( $( $T: ident) ,* ) => {
40
+ ( $( ( $T: ident, $D : ident ) ) ,* ) => {
40
41
#[ allow( non_snake_case) ]
41
42
impl <$( $T: ' static + Send + Sync ) ,* > Unzippable for ( $( $T, ) * )
42
43
{
@@ -75,20 +76,12 @@ macro_rules! impl_unzippable_for_tuple {
75
76
. get_entity_mut( source) . or_broken( ) ?
76
77
. take_input:: <Self >( ) ?;
77
78
78
- // Targets is cloned to avoid borrow checker issues when
79
- // doing a mutable borrow of the world later
80
- let targets = world. get:: <ForkTargetStorage >( source) . or_broken( ) ?. clone( ) ;
81
- // The compiler throws a warning when implementing this for
82
- // tuple sizes that wouldn't use the result of the first _idx = _idx + 1
83
- // so we add a leading underscore to suppress the warning
84
- let mut _idx = 0 ;
79
+ let ( $( $D, ) * ) = world. get:: <ForkTargetStorage >( source) . or_broken( ) ?. 0 . iter( ) . copied( ) . next_tuple( ) . or_broken( ) ?;
85
80
let ( $( $T, ) * ) = inputs;
86
81
$(
87
- let target = * targets. 0 . get( _idx) . or_broken( ) ?;
88
- if let Some ( mut t_mut) = world. get_entity_mut( target) {
82
+ if let Some ( mut t_mut) = world. get_entity_mut( $D) {
89
83
t_mut. give_input( session, $T, roster) ?;
90
84
}
91
- _idx = _idx + 1 ;
92
85
) *
93
86
Ok ( ( ) )
94
87
}
@@ -102,9 +95,10 @@ macro_rules! impl_unzippable_for_tuple {
102
95
}
103
96
}
104
97
105
- // Implements the `Unzippable` trait for all tuples between size 1 and 15
98
+ // Implements the `Unzippable` trait for all tuples between size 1 and 12
106
99
// (inclusive) made of 'static lifetime types that are `Send` and `Sync`
107
- all_tuples ! ( impl_unzippable_for_tuple, 1 , 15 , T ) ;
100
+ // D is a dummy type
101
+ all_tuples ! ( impl_unzippable_for_tuple, 1 , 12 , T , D ) ;
108
102
109
103
/// A trait for constructs that are able to perform a forking unzip of an
110
104
/// unzippable chain. An unzippable chain is one whose response type contains a
@@ -134,5 +128,5 @@ macro_rules! impl_unzipbuilder_for_tuple {
134
128
}
135
129
}
136
130
137
- // Implements the `UnzipBuilder` trait for all tuples between size 1 and 15
138
- all_tuples ! ( impl_unzipbuilder_for_tuple, 2 , 15 , A , F , U ) ;
131
+ // Implements the `UnzipBuilder` trait for all tuples between size 1 and 12
132
+ all_tuples ! ( impl_unzipbuilder_for_tuple, 2 , 12 , A , F , U ) ;
0 commit comments