diff options
| author | Philipp A | 2019-03-31 23:21:45 +0200 |
|---|---|---|
| committer | Philipp A | 2019-03-31 23:21:45 +0200 |
| commit | 4e22848e3faa255c34fdc1b6503a88a02a7350c5 (patch) | |
| tree | d6875de0087de8ab01263fb4f93a6f4457caafd1 /src/document_tree/macro_util.rs | |
| parent | 33f1186bfb5deb0db5ae29d26daf18dbe38fd21a (diff) | |
| download | rust-rst-4e22848e3faa255c34fdc1b6503a88a02a7350c5.tar.bz2 | |
Convert indentation to tabs
Diffstat (limited to 'src/document_tree/macro_util.rs')
| -rw-r--r-- | src/document_tree/macro_util.rs | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/src/document_tree/macro_util.rs b/src/document_tree/macro_util.rs index 84e1b29..d9b8a3e 100644 --- a/src/document_tree/macro_util.rs +++ b/src/document_tree/macro_util.rs @@ -1,42 +1,42 @@ macro_rules! cartesian_impl { - ($out:tt [] $b:tt $init_b:tt $submacro:tt) => { - $submacro!{$out} - }; - ($out:tt [$a:tt, $($at:tt)*] [] $init_b:tt $submacro:tt) => { - cartesian_impl!{$out [$($at)*] $init_b $init_b $submacro} - }; - ([$($out:tt)*] [$a:tt, $($at:tt)*] [$b:tt, $($bt:tt)*] $init_b:tt $submacro:tt) => { - cartesian_impl!{[$($out)* ($a, $b),] [$a, $($at)*] [$($bt)*] $init_b $submacro} - }; + ($out:tt [] $b:tt $init_b:tt $submacro:tt) => { + $submacro!{$out} + }; + ($out:tt [$a:tt, $($at:tt)*] [] $init_b:tt $submacro:tt) => { + cartesian_impl!{$out [$($at)*] $init_b $init_b $submacro} + }; + ([$($out:tt)*] [$a:tt, $($at:tt)*] [$b:tt, $($bt:tt)*] $init_b:tt $submacro:tt) => { + cartesian_impl!{[$($out)* ($a, $b),] [$a, $($at)*] [$($bt)*] $init_b $submacro} + }; } macro_rules! cartesian { - ( $submacro:tt, [$($a:tt)*], [$($b:tt)*]) => { - cartesian_impl!{[] [$($a)*,] [$($b)*,] [$($b)*,] $submacro} - }; + ( $submacro:tt, [$($a:tt)*], [$($b:tt)*]) => { + cartesian_impl!{[] [$($a)*,] [$($b)*,] [$($b)*,] $submacro} + }; } #[cfg(test)] mod test { - macro_rules! print_cartesian { - ( [ $(($a1:tt, $a2:tt)),* , ] ) => { - fn test_f(x:i64, y:i64) -> Result<(i64, i64), ()> { - match (x, y) { - $( - ($a1, $a2) => { Ok(($a1, $a2)) } - )* - _ => { Err(()) } - } - } - }; - } + macro_rules! print_cartesian { + ( [ $(($a1:tt, $a2:tt)),* , ] ) => { + fn test_f(x:i64, y:i64) -> Result<(i64, i64), ()> { + match (x, y) { + $( + ($a1, $a2) => { Ok(($a1, $a2)) } + )* + _ => { Err(()) } + } + } + }; + } - #[test] - fn test_print_cartesian() { - cartesian!(print_cartesian, [1, 2, 3], [4, 5, 6]); - assert_eq!(test_f(1, 4), Ok((1, 4))); - assert_eq!(test_f(1, 3), Err(())); - assert_eq!(test_f(3, 5), Ok((3, 5))); - } + #[test] + fn test_print_cartesian() { + cartesian!(print_cartesian, [1, 2, 3], [4, 5, 6]); + assert_eq!(test_f(1, 4), Ok((1, 4))); + assert_eq!(test_f(1, 3), Err(())); + assert_eq!(test_f(3, 5), Ok((3, 5))); + } } |
