From 06d834e3a57abefdfd0356f464219323a2af5158 Mon Sep 17 00:00:00 2001 From: Pierre-Henri Symoneaux Date: Tue, 18 Sep 2018 10:32:31 +0200 Subject: Implemented horizontal span Updated rust compatibility Fixed UT Added span support from macro Example + updated README Small update to README --- examples/span.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 examples/span.rs (limited to 'examples') 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 -- cgit v1.2.3