pub trait MarkdownTableRow {
// Required methods
fn column_names() -> Vec<&'static str>;
fn column_values(&self) -> Vec<String>;
}Expand description
A trait for types that can be formatted as a row in a markdown table.
Implement this trait to enable formatting your custom types as markdown table rows.
§Example
use markdown_tables::MarkdownTableRow;
struct Product {
id: u32,
name: String,
price: f64,
}
impl MarkdownTableRow for Product {
fn column_names() -> Vec<&'static str> {
vec!["ID", "Product", "Price"]
}
fn column_values(&self) -> Vec<String> {
vec![
self.id.to_string(),
self.name.clone(),
format!("${:.2}", self.price),
]
}
}Required Methods§
Sourcefn column_names() -> Vec<&'static str>
fn column_names() -> Vec<&'static str>
The names of the columns in the table (used for the header row)
Sourcefn column_values(&self) -> Vec<String>
fn column_values(&self) -> Vec<String>
The values of the columns in the table
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.