array/array.rs
1//! This example shows how you can create tables out of arrays.
2
3use kitty_table::TableFormatter;
4
5pub fn main() {
6 // Create a table using the default formatter for [&str; 3], the
7 // type we are supplying into it.
8 let table = TableFormatter::from_style();
9
10 // Put the data we want to print into a collection.
11 let data = [
12 ["These", "arrays", "need"],
13 ["to", "be", "the"],
14 ["same", "size", ":)"]
15 ];
16
17 // Call debug_print to write the output to console— use
18 // "let _ = ..." to ignore the output.
19 let _ = table.debug_print(data);
20}
21
22/*
23Expected result:
24
25┏━━━━━━━━━┯━━━━━━━━━━┯━━━━━━━━┓
26┃ "These" │ "arrays" │ "need" ┃
27┠─────────┼──────────┼────────┨
28┃ "to" │ "be" │ "the" ┃
29┠─────────┼──────────┼────────┨
30┃ "same" │ "size" │ ":)" ┃
31┗━━━━━━━━━┷━━━━━━━━━━┷━━━━━━━━┛
32 */