Skip to content

Commit db15246

Browse files
committed
Avoid using macros in type position
1 parent d8f756e commit db15246

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

src/dimension/conversion.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,19 @@ macro_rules! index {
2727
($m:ident $arg:tt 7) => ($m!($arg 0 1 2 3 4 5 6));
2828
}
2929

30+
macro_rules! index_item_ix {
31+
($m:ident $arg:tt 0) => ($m!($arg););
32+
($m:ident $arg:tt 1) => ($m!($arg Ix););
33+
($m:ident $arg:tt 2) => ($m!($arg Ix Ix););
34+
($m:ident $arg:tt 3) => ($m!($arg Ix Ix Ix););
35+
($m:ident $arg:tt 4) => ($m!($arg Ix Ix Ix Ix););
36+
($m:ident $arg:tt 5) => ($m!($arg Ix Ix Ix Ix Ix););
37+
($m:ident $arg:tt 6) => ($m!($arg Ix Ix Ix Ix Ix Ix););
38+
($m:ident $arg:tt 7) => ($m!($arg Ix Ix Ix Ix Ix Ix Ix););
39+
}
40+
3041
macro_rules! index_item {
31-
($m:ident $arg:tt 0) => ();
42+
($m:ident $arg:tt 0) => ($m!($arg););
3243
($m:ident $arg:tt 1) => ($m!($arg 0););
3344
($m:ident $arg:tt 2) => ($m!($arg 0 1););
3445
($m:ident $arg:tt 3) => ($m!($arg 0 1 2););
@@ -98,8 +109,14 @@ macro_rules! array_zero {
98109
macro_rules! tuple_to_array {
99110
([] $($n:tt)*) => {
100111
$(
112+
index_item_ix!(impl_tuple_to_array [$n] $n);
113+
)*
114+
}
115+
}
116+
macro_rules! impl_tuple_to_array {
117+
([$n:tt] $($ix:tt)*) => {
101118
impl Convert for [Ix; $n] {
102-
type To = index!(tuple_type [Ix] $n);
119+
type To = ($($ix ,)*);
103120
fn convert(self) -> Self::To {
104121
index!(tuple_expr [self] $n)
105122
}
@@ -113,7 +130,7 @@ macro_rules! tuple_to_array {
113130
}
114131
}
115132

116-
impl IntoDimension for index!(tuple_type [Ix] $n) {
133+
impl IntoDimension for ($($ix ,)*) {
117134
type Dim = Dim<[Ix; $n]>;
118135
#[inline(always)]
119136
fn into_dimension(self) -> Self::Dim {
@@ -145,8 +162,6 @@ macro_rules! tuple_to_array {
145162
self.slice().iter().all(|x| *x == 0)
146163
}
147164
}
148-
149-
)*
150165
}
151166
}
152167

0 commit comments

Comments
 (0)