X-Git-Url: http://git.scottworley.com/tablify/blobdiff_plain/25fd008e11cc44e03ddf0ac12da513c27bfe7a95..58c0a717743d262025e664eb6ce79ad9cd4c7968:/src/lib.rs?ds=sidebyside diff --git a/src/lib.rs b/src/lib.rs index 47e1d3a..f1da5f7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -187,7 +187,7 @@ fn column_order(rows: &[Row]) -> Vec { .collect() } -fn render_instance(instance: &Option) -> HTML { +fn render_one_instance(instance: &Option) -> HTML { match instance { None => HTML::from("✓"), Some(instance) => HTML::escape(instance.as_ref()), @@ -212,7 +212,7 @@ fn render_cell(col: &str, row: &mut Row) -> HTML { instances .unwrap() .iter() - .map(render_instance) + .map(render_one_instance) .map(|html| html.0) // Waiting for slice_concat_trait to stabilize .collect::>() .join(" "), @@ -226,12 +226,12 @@ fn render_cell(col: &str, row: &mut Row) -> HTML { fn render_row(columns: &[String], row: &mut Row) -> HTML { let row_label = HTML::escape(row.label.as_ref()); + let cells = columns + .iter() + .map(|col| render_cell(col, row)) + .collect::(); HTML(format!( - "{row_label}{}\n", - &columns - .iter() - .map(|col| render_cell(col, row)) - .collect::() + "{row_label}{cells}\n" )) }