| Crates.io | ascii_table |
| lib.rs | ascii_table |
| version | 4.0.7 |
| created_at | 2019-05-13 20:41:35.258716+00 |
| updated_at | 2025-05-14 20:14:13.849083+00 |
| description | Print ASCII tables to the terminal |
| homepage | https://gitlab.com/d5b4b2/ascii-table |
| repository | https://gitlab.com/d5b4b2/ascii-table |
| max_upload_size | |
| id | 134081 |
| size | 49,123 |
Print ASCII tables to the terminal.
use ascii_table::AsciiTable;
let ascii_table = AsciiTable::default();
let data = vec![&[1, 2, 3], &[4, 5, 6], &[7, 8, 9]];
ascii_table.print(data);
// ┌───┬───┬───┐
// │ 1 │ 2 │ 3 │
// │ 4 │ 5 │ 6 │
// │ 7 │ 8 │ 9 │
// └───┴───┴───┘
use std::fmt::Display;
use ascii_table::{AsciiTable, Align};
let mut ascii_table = AsciiTable::default();
ascii_table.set_max_width(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: Vec<Vec<&dyn Display>> = vec![
vec![&'v', &'v', &'v'],
vec![&123, &456, &789, &"abcdef"]
];
ascii_table.print(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).