use tabled::{
settings::{
object::Segment,
style::{BorderSpanCorrection, Style},
Alignment, Modify, Panel, Width,
},
Table, Tabled,
};
#[derive(Tabled)]
struct Release {
version: &'static str,
published_date: &'static str,
is_active: bool,
major_feature: &'static str,
}
impl Release {
const fn new(v: &'static str, p: &'static str, active: bool, feature: &'static str) -> Self {
Self {
version: v,
published_date: p,
is_active: active,
major_feature: feature,
}
}
}
const DATA: [Release; 3] = [
Release::new("0.2.1", "2021-06-23", true, "#[header(inline)] attribute"),
Release::new("0.2.0", "2021-06-19", false, "API changes"),
Release::new("0.1.4", "2021-06-07", false, "display_with attribute"),
];
fn main() {
let mut table = Table::new(DATA);
table
.with(Panel::header("Tabled Releases"))
.with(Panel::footer(format!("N - {}", DATA.len())))
.with(Panel::vertical(0, "Some text goes here"))
.with(Panel::vertical(5, "Some text goes here"))
.with(Modify::new((0, 0)).with(Width::wrap(1)))
.with(Modify::new((0, 5)).with(Width::wrap(1)))
.with(Modify::new(Segment::all()).with(Alignment::center()))
.with(Style::modern())
.with(BorderSpanCorrection);
println!("{table}");
}