Tabled [v0.4.0] - An easy to use library for pretty print tables of Rust structs and enums.

28 points zhiburt

https://github.com/zhiburt/tabled

​

There is a list of main additions.

  • Highlight modifier which does highlight of any combination of cells.
  • Concat modifier which does concatenation of two tables into one.
  • TableIteratorExt trait which can be used to create table from \Iterator\\.

An example bellow shows usage of each of these features.

use tabled::{Border, Concat, Highlight, Style, TableIteratorExt};

fn main() {
    let data = vec![["A", "B", "C"], ["D", "E", "F"], ["G", "H", "I"]];

    let table = (0..data.len())
        .table()
        .with(Concat::horizontal(data.table()))
        .with(Style::PSEUDO)
        .with(Highlight::cell(
            2,
            2,
            Border::full('*', '*', '*', '*', '*', '*', '*', '*'),
        ));

    println!("{}", table);
}

The printed result.

┌───────┬───┬───┬───┐
│ usize │ 0 │ 1 │ 2 │
├───────┼───┼───┼───┤
│   0   │ A │ B │ C │
├───────┼───*****───┤
│   1   │ D * E * F │
├───────┼───*****───┤
│   2   │ G │ H │ I │
└───────┴───┴───┴───┘