static_table!() { /* proc-macro */ }Expand description
Build a table.
use static_table::static_table;
let table = static_table!([
[{"programming languages"; 3}],
["name", "designed by", "first release"],
["C", "Dennis Ritchie", "1972"],
["Go", "Rob Pike", "2009"],
["Rust", "Graydon Hoare", "2010"],
["Hare", "Drew DeVault", "2022"],
]);
assert_eq!(
table,
"+---------------------------------------+\n\
| programming languages |\n\
+------+----------------+---------------+\n\
| name | designed by | first release |\n\
+------+----------------+---------------+\n\
| C | Dennis Ritchie | 1972 |\n\
+------+----------------+---------------+\n\
| Go | Rob Pike | 2009 |\n\
+------+----------------+---------------+\n\
| Rust | Graydon Hoare | 2010 |\n\
+------+----------------+---------------+\n\
| Hare | Drew DeVault | 2022 |\n\
+------+----------------+---------------+"
);
§Syntax
The input is expected to look like an array.
static_table!([["a", "b"], ["c", "d"]]);You can repeat an argument just like you’d do with general array of vec! macro.
static_table!([["123456789"; 2]; 5]);Optionally you can set a column span, using the following syntax.
static_table!([[{"a"; 2}], ["c", "d"]]);Optionally you can set a row span, using the following syntax.
static_table!([[{"a"}, "b"], [{ }, "d"]]);Optionally you can add settings to the table, using the following syntax.
static_table!([["a", "b"], ["c", "d"]], THEME = "ROUNDED");Supported settings are:
- THEME
- ALIGNMENT
- PADDING
- MARGIN