feat: update tabled

This commit is contained in:
2022-06-24 00:35:45 +08:00
parent af706d9abb
commit 22e77db82c

View File

@@ -7,25 +7,81 @@ struct Language {
invented_year: usize,
}
#[derive(Tabled)]
struct TagData {
tag: String,
description: String,
alive: usize,
total: usize,
uploaded: String,
downloaded: String,
up_speed: String,
down_speed: String,
}
fn main() {
let languages = vec![
Language{
let languages = vec![
Language {
name: "C",
designed_by: "Dennis Ritchie",
invented_year: 1972
invented_year: 1972,
},
Language{
Language {
name: "Rust",
designed_by: "Graydon Hoare",
invented_year: 2010
invented_year: 2010,
},
Language{
Language {
name: "Go",
designed_by: "Rob Pike",
invented_year: 2009
invented_year: 2009,
},
];
];
let table = Table::new(languages).to_string();
println!("{}", table);
let table = Table::new(languages).to_string();
println!("{}", table);
let table2 = Table::new(vec![
TagData {
tag: "0.0.0.0:9901".into(),
description: "47.--.--.--:3443".into(),
alive: 0,
total: 10,
uploaded: "1.11MB".into(),
downloaded: "1.11MB".into(),
up_speed: "0/s".into(),
down_speed: "0/s".into(),
},
TagData {
tag: "0.0.0.0:9902".into(),
description: "47.---.--.--:2443".into(),
alive: 0,
total: 2294,
uploaded: "26.28MB".into(),
downloaded: "828.52MB".into(),
up_speed: "100/s".into(),
down_speed: "476/s".into(),
},
TagData {
tag: "0.0.0.0:9909".into(),
description: "47.---.--.--:9909".into(),
alive: 22,
total: 19776,
uploaded: "254.50MB".into(),
downloaded: "4.38GB".into(),
up_speed: "1.83KB/s".into(),
down_speed: "36.09KB/s".into(),
},
TagData {
tag: "<total>".into(),
description: "-".into(),
alive: 22,
total: 22182,
uploaded: "281.91MB".into(),
downloaded: "5.24GB".into(),
up_speed: "1.83KB/s".into(),
down_speed: "36.09KB/s".into(),
},
]).to_string();
println!("{}", table2);
}