mirror of
https://github.com/sharkdp/hyperfine.git
synced 2026-11-02 17:11:28 +00:00
table_data => table_row
This commit is contained in:
1 parent
7fdb32d202
commit
5cd2821266
2 files changed
+7
-8
No files matched your search
@@ -4,7 +4,7 @@ use crate::export::markup::MarkupExporter;
|
|||||||
pub struct MarkdownExporter {}
|
pub struct MarkdownExporter {}
|
||||||
|
|
||||||
impl MarkupExporter for MarkdownExporter {
|
impl MarkupExporter for MarkdownExporter {
|
||||||
fn table_data(&self, data: &[&str]) -> String {
|
fn table_row(&self, data: &[&str]) -> String {
|
||||||
format!("| {} |\n", data.join(" | "))
|
format!("| {} |\n", data.join(" | "))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,9 +21,8 @@ impl MarkupExporter for MarkdownExporter {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_markdown_formatter_table_data() {
|
fn test_markdown_formatter_table_data() {
|
||||||
let formatter = MarkdownExporter::default();
|
let formatter = MarkdownExporter::default();
|
||||||
let data = vec!["a", "b", "c"];
|
|
||||||
|
|
||||||
let actual = formatter.table_data(&data);
|
let actual = formatter.table_row(&["a", "b", "c"]);
|
||||||
let expect = "| a | b | c |\n";
|
let expect = "| a | b | c |\n";
|
||||||
|
|
||||||
assert_eq!(expect, actual);
|
assert_eq!(expect, actual);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ pub trait MarkupExporter {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// emit header
|
// emit header
|
||||||
let mut table = self.table_data(&head);
|
let mut table = self.table_row(&head);
|
||||||
|
|
||||||
// emit horizontal line
|
// emit horizontal line
|
||||||
table.push_str(&self.table_line(head.len()));
|
table.push_str(&self.table_line(head.len()));
|
||||||
@@ -44,21 +44,21 @@ pub trait MarkupExporter {
|
|||||||
} else {
|
} else {
|
||||||
"".into()
|
"".into()
|
||||||
};
|
};
|
||||||
|
|
||||||
// prepare table row entries
|
// prepare table row entries
|
||||||
let data: [&str; 5] = [
|
table.push_str(&self.table_row(&[
|
||||||
&self.command(&cmd_str),
|
&self.command(&cmd_str),
|
||||||
&format!("{}{}", mean_str, stddev_str),
|
&format!("{}{}", mean_str, stddev_str),
|
||||||
&min_str,
|
&min_str,
|
||||||
&max_str,
|
&max_str,
|
||||||
&format!("{}{}", rel_str, rel_stddev_str),
|
&format!("{}{}", rel_str, rel_stddev_str),
|
||||||
];
|
]))
|
||||||
table.push_str(&self.table_data(&data))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
table
|
table
|
||||||
}
|
}
|
||||||
|
|
||||||
fn table_data(&self, data: &[&str]) -> String;
|
fn table_row(&self, data: &[&str]) -> String;
|
||||||
|
|
||||||
fn table_line(&self, size: usize) -> String;
|
fn table_line(&self, size: usize) -> String;
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user