| Crates.io | ascii_table |
| lib.rs | ascii_table |
| version | 5.0.0 |
| created_at | 2019-05-13 20:41:35.258716+00 |
| updated_at | 2025-11-30 10:59:36.805404+00 |
| description | Print ASCII tables to the terminal |
| homepage | |
| repository | |
| max_upload_size | |
| id | 134081 |
| size | 65,541 |
Print ASCII tables to the terminal.
use ::ascii_table::AsciiTable;
let ascii_table = AsciiTable::new();
let data = &[&["1", "2", "3"], &["4", "5", "6"], &["7", "8", "9"]];
ascii_table.println(data);
// ┌───┬───┬───┐
// │ 1 │ 2 │ 3 │
// │ 4 │ 5 │ 6 │
// │ 7 │ 8 │ 9 │
// └───┴───┴───┘
use ::ascii_table::{Align, AsciiTable, Width};
let mut ascii_table = AsciiTable::new();
ascii_table.set_max_width(Width::Fixed(26));
ascii_table
.column(0)
.set_header("H1")
.set_align(Align::Left);
ascii_table
.column(1)
.set_header("H2")
.set_align(Align::Center);
ascii_table
.column(2)
.set_header("H3")
.set_align(Align::Right);
let data: &[&[&str]] = &[&["v", "v", "v"], &["123", "456", "789", "abcdef"]];
ascii_table.println(data);
// ┌─────┬─────┬─────┬──────┐
// │ H1 │ H2 │ H3 │ │
// ├─────┼─────┼─────┼──────┤
// │ v │ v │ v │ │
// │ 123 │ 456 │ 789 │ abc+ │
// └─────┴─────┴─────┴──────┘
auto_table_width: Sets the default max width of the Ascii Table to the width of the terminal.color_codes: Correctly calculates the width of a string when terminal color codes are present
(like those from the colorful crate).wide_characters: Correctly calculates the width of a string when wide characters are present
(like emoji's).Display. You will have to stringify your data before you give it to Ascii Table.termsize with termize to fix a edge-case where it was unable to get the terminal
width on some SSH sessions. This will only affect the auto_table_width feature.lazy_static with std::sync::LazyLock. This change is only for the color_codes
feature.termion with the more lightweight termsize. This will only affect the auto_table_width
feature.auto_table_width. It will set the default max width of your ascii table to
the width of your terminal. Note that AsciiTable::set_max_width will override this value.color_codes. Enable this feature when you want to display
colors in the terminal using the colorful crate.wide_characters who will use unicode rules to determine the width of strings.
Use this feature when you want to display emoji's or other wide characters.