use tabled::{Tabled, Table}; #[derive(Tabled)] struct Language { name: &'static str, designed_by: &'static str, 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 { name: "C", designed_by: "Dennis Ritchie", invented_year: 1972, }, Language { name: "Rust", designed_by: "Graydon Hoare", invented_year: 2010, }, Language { name: "Go", designed_by: "Rob Pike", invented_year: 2009, }, ]; 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: "".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); }