Terminal table rendering with alignment, borders, Unicode support, and ANSI color awareness
cargo add philiprehberger-table-fmtTerminal table rendering with alignment, borders, Unicode support, and ANSI color awareness
[dependencies]
philiprehberger-table-fmt = "0.2.0"
use philiprehberger_table_fmt::{Table, BorderStyle, Alignment};
let table = Table::new()
.header(["Name", "Age", "City"])
.row(["Alice", "30", "New York"])
.row(["Bob", "25", "London"])
.row(["Charlie", "35", "Tokyo"])
.border(BorderStyle::Unicode)
.align(1, Alignment::Right)
.to_string();
println!("{}", table);
| Function / Type | Description |
|---|---|
Table::new() | Create a new table |
.header(cols) | Set column headers |
.row(cols) | Add a data row |
.align(col, alignment) | Set column alignment |
.max_width(col, width) | Limit column width |
.border(style) | Set border style |
.to_string() | Render as string |
.print() | Render and print to stdout |
.to_markdown() | Render as Markdown table |
.to_csv() | Render as CSV |
.to_json() | Render as JSON array of objects |
cargo test
cargo clippy -- -D warnings
If you find this project useful: