4 个版本
使用旧的 Rust 2015
0.0.4 | 2015年2月14日 |
---|---|
0.0.3 | 2015年1月10日 |
0.0.2 | 2015年1月7日 |
0.0.1 | 2014年12月18日 |
#40 in #formatted
10KB
263 代码行,不包括注释
text_table.rs
Text Table 是一个用于从任意数据创建格式化纯文本表的库。
注意:API 目前完全不稳定,并且在使用此库的其他项目中将进行更改。请通过 问题页面 或电子邮件提供反馈。
用法
将 text_table
添加到您的 Cargo.toml
[dependencies]
text_table = "*"
示例
基本示例
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());
}
打印
+----+------------+-----------+--------------+
| 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