1#![cfg_attr(feature = "nightly", feature(allow_internal_unstable, macro_reexport))]
2
3#[cfg(feature = "nightly")]
4#[macro_reexport(lazy_static, __lazy_static_create)]
5#[macro_use]
6extern crate lazy_static;
7
8#[cfg(feature = "nightly")]
9pub use lazy_static::lazy;
10
11#[macro_export]
21macro_rules! counted_array {
22 (@parse $size:expr, ($val:expr) -> [$($accs:expr),*] $thru:tt) => {
26 counted_array!(@output $size + 1usize, [$($accs,)* $val] $thru);
27 };
28 (@parse $size:expr, ($val:expr, $($vals:expr),*) -> [$($accs:expr),*] $thru:tt) => {
30 counted_array!(@parse $size + 1usize, ($($vals),*) -> [$($accs,)* $val] $thru);
31 };
32
33 (@output $size:expr, $acc:tt (() let $n:ident $t:ty)) => {
35 let $n: [$t; $size] = $acc;
36 };
37 (@output $size:expr, $acc:tt (($($p:tt)*) lazy_static $n:ident $t:ty)) => {
39 lazy_static!{ $($p)* static ref $n: [$t; $size] = $acc; }
40 };
41 (@output $size:expr, $acc:tt (($($p:tt)*) $s:ident $n:ident $t:ty)) => {
43 $($p)* $s $n: [$t; $size] = $acc;
44 };
45
46 (pub $storage:ident $n:ident: [$t:ty; _] = [$($vals:expr),* $(,)*]) => {
50 counted_array!(@parse 0usize, ($($vals),*) -> [] ((pub) $storage $n $t));
51 };
52 (pub $restr:tt $storage:ident $n:ident: [$t:ty; _] = [$($vals:expr),* $(,)*]) => {
53 counted_array!(@parse 0usize, ($($vals),*) -> [] ((pub $restr) $storage $n $t));
54 };
55 ($storage:ident $n:ident: [$t:ty; _] = [$($vals:expr),* $(,)*]) => {
56 counted_array!(@parse 0usize, ($($vals),*) -> [] (() $storage $n $t));
57 };
58}
59