#ascii #pretty #table #terminal #pretty-print

text-tables

A terminal/text table prettifier with no dependencies

7 releases

Uses old Rust 2015

0.3.1 Mar 3, 2019
0.3.0 Mar 3, 2019
0.2.3 Feb 27, 2018
0.1.0 Feb 27, 2018

#1879 in Text processing

Download history 591/week @ 2024-07-21 268/week @ 2024-07-28 310/week @ 2024-08-04 204/week @ 2024-08-11 125/week @ 2024-08-18 138/week @ 2024-08-25 234/week @ 2024-09-01 229/week @ 2024-09-08 202/week @ 2024-09-15 168/week @ 2024-09-22 313/week @ 2024-09-29 235/week @ 2024-10-06 208/week @ 2024-10-13 372/week @ 2024-10-20 183/week @ 2024-10-27 147/week @ 2024-11-03

917 downloads per month
Used in 3 crates

MIT/Apache

8KB
113 lines

Text-tables

This library provides very simple table printing using text characters. It has no dependencies besides std. I'm interested in making it no_std if this is possible, contributions welcome!

Licensed under MIT or Apache-2.0 at your discretion. Message me if this isn't sufficient.

Example

extern crate text_tables;

use std::str;
use std::io;

fn main() {
    // can be vec or slices
    let data = [["A", "2x2"], ["pretty", "table"]];
    // we can either render to an array...
    let mut out = Vec::new();
    text_tables::render(&mut out, data).unwrap();
    println!("{}", str::from_utf8(&out).unwrap());
    // ...or we can use `Write` streams directly
    text_tables::render(&mut io::stdout(), data).unwrap();
}

outputs

+--------+-------+
| A      | 2x2   |
+--------+-------+
| pretty | table |
+--------+-------+

lib.rs:

A small library for pretty-printing tables in monospace text.

Example

let data = [["Some", "printable"], ["data", "fields"]];
let mut out = Vec::new();
text_tables::render(&mut out, data).unwrap();
println!("{}", ::std::str::from_utf8(&out).unwrap());

No runtime deps