diff options
author | Pierre-Henri Symoneaux <pierre.henri.symoneaux@gmail.com> | 2018-09-18 10:32:31 +0200 |
---|---|---|
committer | Pierre-Henri Symoneaux <pierre.henri.symoneaux@gmail.com> | 2018-09-18 11:58:38 +0200 |
commit | 06d834e3a57abefdfd0356f464219323a2af5158 (patch) | |
tree | 3480aa3b469b4002dc420a4e2d1ef6089e697188 /examples | |
parent | ceaf8bb7f562b20c6d76f0e803f0bc0b00acdfcc (diff) |
Implemented horizontal span
Updated rust compatibility
Fixed UT
Added span support from macro
Example + updated README
Small update to README
Diffstat (limited to 'examples')
-rw-r--r-- | examples/span.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/span.rs b/examples/span.rs new file mode 100644 index 0000000..61e1815 --- /dev/null +++ b/examples/span.rs @@ -0,0 +1,31 @@ +#[macro_use] +extern crate prettytable; +use prettytable::{row::Row, cell::Cell, format::Alignment}; + + +fn main() { + + /* + The following code will output + + +---------------+---------------+--------------+ + | A table with horizontal span | + +===============+===============+==============+ + | This is a cell with span of 2 | span of 1 | + +---------------+---------------+--------------+ + | span of 1 | span of 1 | span of 1 | + +---------------+---------------+--------------+ + | This cell with a span of 3 is centered | + +---------------+---------------+--------------+ + */ + + let mut table: prettytable::Table = table![ + [H2 -> "This is a cell with span of 2", "span of 1"], + ["span of 1", "span of 1", "span of 1"], + [H03c -> "This cell with a span of 3 is centered"] + ]; + table.set_titles(Row::new(vec![ + Cell::new_align("A table with horizontal span", Alignment::CENTER).with_hspan(3) + ])); + table.printstd(); +}
\ No newline at end of file |