span/span.rs
1use prettytable::format::Alignment;
2use prettytable::{
3 table,
4 Cell,
5 Row,
6};
7
8fn main() {
9 /*
10 The following code will output
11
12 +---------------+---------------+--------------+
13 | A table with horizontal span |
14 +===============+===============+==============+
15 | This is a cell with span of 2 | span of 1 |
16 +---------------+---------------+--------------+
17 | span of 1 | span of 1 | span of 1 |
18 +---------------+---------------+--------------+
19 | This cell with a span of 3 is centered |
20 +---------------+---------------+--------------+
21 */
22
23 let mut table: prettytable::Table = table![
24 [H2 -> "This is a cell with span of 2", "span of 1"],
25 ["span of 1", "span of 1", "span of 1"],
26 [H03c -> "This cell with a span of 3 is centered"]
27 ];
28 table.set_titles(Row::new(vec![Cell::new_align(
29 "A table with horizontal span",
30 Alignment::CENTER,
31 )
32 .with_hspan(3)]));
33 table.printstd();
34}