1#![allow(clippy::needless_doctest_main)]
69
70#[macro_export]
72macro_rules! iota {
73 (const $n:ident : $t:ty = $($rest:tt)+) => {
74 $crate::__iota_dup!((0) const $n : $t = $($rest)+);
75 };
76
77 (pub const $n:ident : $t:ty = $($rest:tt)+) => {
78 $crate::__iota_dup!((0) pub const $n : $t = $($rest)+);
79 };
80}
81
82#[macro_export]
85#[doc(hidden)]
86macro_rules! __iota_dup {
87 (($v:expr)) => {};
88
89 (($v:expr) const $n:ident : $t:ty = $($rest:tt)+) => {
90 $crate::__iota_impl!(($v) () () const $n : $t = ($($rest)+) ($($rest)+));
91 };
92
93 (($v:expr) pub const $n:ident : $t:ty = $($rest:tt)+) => {
94 $crate::__iota_impl!(($v) () (pub) const $n : $t = ($($rest)+) ($($rest)+));
95 };
96}
97
98#[macro_export]
99#[doc(hidden)]
100macro_rules! __iota_impl {
101 (($v:expr) () $vis:tt const $n:ident : $t:ty = (; $($x:tt)*) ($semi:tt $($y:tt)*)) => {
105 $crate::__iota_impl!($semi);
107 };
108
109 (($v:expr) ($($seen:tt)*) $vis:tt const $n:ident : $t:ty = (const $($x:tt)*) ($cons:tt $($y:tt)*)) => {
114 $crate::__iota_impl!($cons);
116 };
117
118 (($v:expr) ($($seen:tt)*) $vis:tt const $n:ident : $t:ty = () $y:tt) => {
122 $crate::__iota_impl!();
124 };
125
126 (($v:expr) ($($seen:tt)+) ($($vis:tt)*) const $n:ident : $t:ty = (; , $i:ident $($rest:tt)*) $y:tt) => {
131 $($vis)* const $n : $t = $crate::__iota_replace!(($v) (()) $($seen)+);
132 $crate::__iota_impl!(($v + 1) ($($seen)+) ($($vis)*) const $i : $t = (; $($rest)*) (; $($rest)*));
133 };
134
135 (($v:expr) ($($seen:tt)+) ($($vis:tt)*) const $n:ident : $t:ty = (; $($rest:tt)*) $y:tt) => {
137 $($vis)* const $n : $t = $crate::__iota_replace!(($v) (()) $($seen)+);
138 $crate::__iota_dup!(($v + 1) $($rest)*);
139 };
140
141 (($v:expr) ($($seen:tt)*) $vis:tt const $n:ident : $t:ty = ($first:tt $($rest:tt)*) $y:tt) => {
143 $crate::__iota_impl!(($v) ($($seen)* $first) $vis const $n : $t = ($($rest)*) ($($rest)*));
144 };
145
146 (($v:expr) ()) => {};
148}
149
150#[macro_export]
151#[doc(hidden)]
152macro_rules! __iota_replace {
153 (($v:expr) ($($stack:tt)*) ($($first:tt)*) $($rest:tt)*) => {
155 $crate::__iota_replace!(($v) (() $($stack)*) $($first)* __iota_close_paren $($rest)*)
156 };
157
158 (($v:expr) ($($stack:tt)*) [$($first:tt)*] $($rest:tt)*) => {
160 $crate::__iota_replace!(($v) (() $($stack)*) $($first)* __iota_close_bracket $($rest)*)
161 };
162
163 (($v:expr) ($($stack:tt)*) {$($first:tt)*} $($rest:tt)*) => {
165 $crate::__iota_replace!(($v) (() $($stack)*) $($first)* __iota_close_brace $($rest)*)
166 };
167
168 (($v:expr) (($($close:tt)*) ($($top:tt)*) $($stack:tt)*) __iota_close_paren $($rest:tt)*) => {
170 $crate::__iota_replace!(($v) (($($top)* ($($close)*)) $($stack)*) $($rest)*)
171 };
172
173 (($v:expr) (($($close:tt)*) ($($top:tt)*) $($stack:tt)*) __iota_close_bracket $($rest:tt)*) => {
175 $crate::__iota_replace!(($v) (($($top)* [$($close)*]) $($stack)*) $($rest)*)
176 };
177
178 (($v:expr) (($($close:tt)*) ($($top:tt)*) $($stack:tt)*) __iota_close_brace $($rest:tt)*) => {
180 $crate::__iota_replace!(($v) (($($top)* {$($close)*}) $($stack)*) $($rest)*)
181 };
182
183 (($v:expr) (($($top:tt)*) $($stack:tt)*) iota $($rest:tt)*) => {
185 $crate::__iota_replace!(($v) (($($top)* $v) $($stack)*) $($rest)*)
186 };
187
188 (($v:expr) (($($top:tt)*) $($stack:tt)*) $first:tt $($rest:tt)*) => {
190 $crate::__iota_replace!(($v) (($($top)* $first) $($stack)*) $($rest)*)
191 };
192
193 (($v:expr) (($($top:tt)+))) => {
195 $($top)+
196 };
197}