Macro pretty_table::print_table
source · macro_rules! print_table { ($rows:expr) => { ... }; ($($row:expr), +) => { ... }; }
Expand description
This is a simple macro that takes 1 or more number of Vectors of any type that’s coersable into String type, and print them as
pretty-formatted table in the standard output.
Example
use pretty_table::prelude::*;
fn main() {
// usage with individual rows
print_table!(
vec!["Name", "Age", "Salary"], // header
vec!["Altmann", "45", "11.0k"],
vec!["Bezos", "32", "99.34k"],
vec!["Pichai", "56", "9.9m"],
vec!["Cook", "43", "8.2m"]
);
// usage with table data
print_table!(
vec![
vec!["Name", "Age", "Salary"], // header
vec!["Altmann", "45", "11.0k"],
vec!["Bezos", "32", "99.34k"],
vec!["Pichai", "56", "9.9m"],
vec!["Cook", "43", "8.2m"]
]
);
}