diff options
author | Pierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com> | 2017-12-03 12:24:58 +0100 |
---|---|---|
committer | Pierre-Henri Symoneaux <pierre-henri.symoneaux@nokia.com> | 2017-12-03 12:24:58 +0100 |
commit | 31ff6acd4b69338a1e177c51406136980f6127af (patch) | |
tree | f434c9b76b0459579bc58b3d7fc503ee9a93afcc /src | |
parent | 2534cd8cbf3b15183c82d621ec9b12ef2a382782 (diff) |
Fix #68 Trailing comma in macros
Now trailing commas are supported in macros and won't trigger an infinite recursion anymore during marco expansion
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 1 | ||||
-rw-r--r-- | src/row.rs | 3 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index dcd8aa8..2bac3e6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,3 @@ -//#![feature(trace_macros)] #[macro_use] extern crate prettytable; extern crate term; @@ -239,13 +239,14 @@ impl<'a> IntoIterator for &'a mut Row { /// For details about style specifier syntax, check doc for [`Cell::style_spec`](cell/struct.Cell.html#method.style_spec) method #[macro_export] macro_rules! row { + (($($out:tt)*);) => (vec![$($out)*]); (($($out:tt)*); $value:expr) => (vec![$($out)* cell!($value)]); (($($out:tt)*); $value:expr, $($n:tt)*) => (row!(($($out)* cell!($value),); $($n)*)); (($($out:tt)*); $style:ident -> $value:expr) => (vec![$($out)* cell!($style -> $value)]); (($($out:tt)*); $style:ident -> $value:expr, $($n: tt)*) => (row!(($($out)* cell!($style -> $value),); $($n)*)); - ($($content:expr), *) => ($crate::row::Row::new(vec![$(cell!($content)), *])); ($style:ident => $($content:expr), *) => ($crate::row::Row::new(vec![$(cell!($style -> $content)), *])); + ($style:ident => $($content:expr,) *) => ($crate::row::Row::new(vec![$(cell!($style -> $content)), *])); ($($content:tt)*) => ($crate::row::Row::new(row!((); $($content)*))); } |