Debian Codegraph @

examples/readme_table.rs

raw symbols SCIP
1 use comfy_table::{presets::UTF8_FULL, *};
2
3 fn main() {
4 let mut table = Table::new();
5 table.load_preset(UTF8_FULL)
6 .set_content_arrangement(ContentArrangement::Dynamic)
7 .set_width(80)
8 .set_header(vec![
9 Cell::new("Header1").add_attribute(Attribute::Bold),
10 Cell::new("Header2").fg(Color::Green),
11 Cell::new("Header3"),
12 ])
13 .add_row(vec![
14 Cell::new("This is a bold text").add_attribute(Attribute::Bold),
15 Cell::new("This is a green text").fg(Color::Green),
16 Cell::new("This one has black background").bg(Color::Black),
17 ])
18 .add_row(vec![
19 Cell::new("Blinky boi").add_attribute(Attribute::SlowBlink),
20 Cell::new("This table's content is dynamically arranged. The table is exactly 80 characters wide.\nHere comes a reallylongwordthatshoulddynamicallywrap"),
21 Cell::new("COMBINE ALL THE THINGS")
22 .fg(Color::Green)
23 .bg(Color::Black)
24 .add_attributes(vec![
25 Attribute::Bold,
26 Attribute::SlowBlink,
27 ])
28 ]);
29
30 println!("{table}");
31 }