Created
April 19, 2017 09:13
-
-
Save qryxip/8d53aebc9a223c0c1fff5686e64529b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
macro_rules! array { | |
[$x: tt; $n: tt] => {array!(@go ($n, $x) -> ())}; | |
(@end $x: tt) => {$x}; | |
(@go (1, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@end [$($x,)* $($xs)*]) }; | |
(@go (2, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (1, $($x), *) -> ($($x,)* $($xs)*))}; | |
(@go (3, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (2, $($x), *) -> ($($x,)* $($xs)*))}; | |
(@go (4, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (2, $($x,)* $($x), *) -> ($($xs)*))}; | |
(@go (5, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (4, $($x), *) -> ($($x,)* $($xs)*))}; | |
(@go (6, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (3, $($x,)* $($x), *) -> ($($xs)*))}; | |
(@go (8, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (4, $($x,)* $($x), *) -> ($($xs)*))}; | |
(@go (10, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (5, $($x,)* $($x), *) -> ($($xs)*))}; | |
(@go (12, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (6, $($x,)* $($x), *) -> ($($xs)*))}; | |
(@go (16, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (8, $($x,)* $($x), *) -> ($($xs)*))}; | |
(@go (24, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (12, $($x,)* $($x), *) -> ($($xs)*))}; | |
(@go (25, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (24, $($x), *) -> ($($x,)* $($xs)*))}; | |
(@go (50, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (25, $($x,)* $($x), *) -> ($($xs)*))}; | |
(@go (100, $($x: tt), *) -> ($($xs: tt)*)) => {array!(@go (50, $($x,)* $($x), *) -> ($($xs)*))}; | |
} | |
#[test] | |
fn test() { | |
let a: [String; 100] = array![{ format!["はろー!"] }; 100]; | |
for s in a.iter() { | |
assert_eq!("はろー!", s); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment