Text Table is a library to create formatted plain-text tables from arbitrary data.
NOTE: The API is currently completely unstable, and it will change as I use this library in other projects. Feedback highly appreciated via the issues page or email.
Add text_table
to your Cargo.toml
:
toml
[dependencies]
text_table = "*"
``` extern crate texttable; use texttable::Table;
fn main() { let mut table = Table::new(); table.row(("ID", "First Name", "Last Name", "Phone Number")) .sep() .row((1u, "Tammy", "Bailey", "496-914-5526")) .row((2u, "Kathy", "Reynolds", "092-281-4890")) .row((3u, "Edward", "Ramirez", "940-289-6874")) .row((4u, "Robert", "Payne", "295-850-6147")) .row((5u, "Roy", "Larson", "133-661-1680")); println!("{}", table.writetostring()); } ```
prints
+----+------------+-----------+--------------+
| ID | First Name | Last Name | Phone Number |
+----+------------+-----------+--------------+
| 1 | Tammy | Bailey | 496-914-5526 |
| 2 | Kathy | Reynolds | 092-281-4890 |
| 3 | Edward | Ramirez | 940-289-6874 |
| 4 | Robert | Payne | 295-850-6147 |
| 5 | Roy | Larson | 133-661-1680 |
+----+------------+-----------+--------------+
MIT