summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpierresy <pierre-henri.symoneaux@alcatel-lucent.com>2015-06-18 22:20:51 +0200
committerpierresy <pierre-henri.symoneaux@alcatel-lucent.com>2015-06-18 22:20:51 +0200
commit8b3aa5ab7b88059641c27f7ff2fcfcc0ec1aa4b2 (patch)
treed62c42eb4ee5e97f98b9ae7684aac952df126272
parentf1da0232d65703f62ea0ab8a2019276f4f7339a7 (diff)
Fixed issue with ptable! macro
-rw-r--r--TODO.md1
-rw-r--r--examples/basic.rs6
-rw-r--r--src/lib.rs4
-rw-r--r--src/main.rs3
4 files changed, 11 insertions, 3 deletions
diff --git a/TODO.md b/TODO.md
index 8403985..e751d48 100644
--- a/TODO.md
+++ b/TODO.md
@@ -12,5 +12,4 @@
* Learn how to do unit testing in Rust, and add some
## Travis-CI :
-* Publish doc in github pages
* Automatically publish API documentation with travis after each successfull build
diff --git a/examples/basic.rs b/examples/basic.rs
index 3be3153..13cc661 100644
--- a/examples/basic.rs
+++ b/examples/basic.rs
@@ -40,4 +40,10 @@ fn main() {
["foobar", "bar", "foo"],
["foobar2", "bar2", "foo2"]
);
+
+ // Or directly print it like this
+ let _table = table!(["ABC", "DEFG", "HIJKLMN"],
+ ["foobar", "bar", "foo"],
+ ["foobar2", "bar2", "foo2"]
+ );
}
diff --git a/src/lib.rs b/src/lib.rs
index f45ad55..4fd2655 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -221,9 +221,9 @@ macro_rules! table {
/// The syntax is the same that the one for the `table!` macro
#[macro_export]
macro_rules! ptable {
- ([$($value: expr), *]) => (
+ ($([$($value: expr), *]), *) => (
{
- let tab = table!([$($value), *]);
+ let tab = table!($([$($value), *]), *);
tab.printstd();
tab
}
diff --git a/src/main.rs b/src/main.rs
index 6f48ae1..0096b5d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -19,9 +19,12 @@ fn main() {
table.set_element(&"new_foo".to_string(), 2, 1).unwrap();
table.printstd();
+ ptable!(["A", "B", "C"], [1, 2, 3, 4]);
+
let mut table = table!(["A", "B", "C"], [1, 2, 3, 4], ["A\nBCCZZZ\nDDD", 2, table]);
table.set_titles(row!["Title 1", "Title 2"]);
table.set_format(FORMAT_DEFAULT);
table.printstd();
println!("{:?}", table);
+
}