4 releases
Uses old Rust 2015
0.0.4 | Feb 14, 2015 |
---|---|
0.0.3 | Jan 10, 2015 |
0.0.2 | Jan 7, 2015 |
0.0.1 | Dec 18, 2014 |
#40 in #formatted
10KB
263 lines
text_table.rs
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.
Usage
Add text_table
to your Cargo.toml
:
[dependencies]
text_table = "*"
Example
Basic Example
extern crate text_table;
use text_table::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.write_to_string());
}
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 |
+----+------------+-----------+--------------+
License
MIT