From b4bc28bae91f901f88fdad4621b14da9eb18be06 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 3 Oct 2024 21:41:11 -0700 Subject: [PATCH] Plumb Config into render_all_leftovers() --- src/lib.rs | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 6d147dd..99c454d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -308,7 +308,7 @@ fn render_leftover(notcol: &str, instances: &[Option]) -> HTML { } } -fn render_all_leftovers(row: &Row) -> HTML { +fn render_all_leftovers(config: &Config, row: &Row) -> HTML { let mut order: Vec<_> = row.entries.keys().collect(); order.sort_unstable(); HTML( @@ -338,7 +338,7 @@ fn render_row(config: &Config, columns: &[String], rowlike: &mut Rowlike) -> HTM .iter() .map(|col| render_cell(col, row)) .collect::(); - let leftovers = render_all_leftovers(row); + let leftovers = render_all_leftovers(config, row); HTML(format!( "{row_label}{static_cells}{dynamic_cells}{leftovers}\n" )) @@ -695,30 +695,39 @@ mod tests { #[test] fn test_render_leftovers() { assert_eq!( - render_all_leftovers(&Row { - label: "nope".to_owned(), - entries: HashMap::from([("foo".to_owned(), vec![None])]), - }), + render_all_leftovers( + &Config::default(), + &Row { + label: "nope".to_owned(), + entries: HashMap::from([("foo".to_owned(), vec![None])]), + } + ), HTML::from("foo") ); assert_eq!( - render_all_leftovers(&Row { - label: "nope".to_owned(), - entries: HashMap::from([ - ("foo".to_owned(), vec![None]), - ("bar".to_owned(), vec![None]) - ]), - }), + render_all_leftovers( + &Config::default(), + &Row { + label: "nope".to_owned(), + entries: HashMap::from([ + ("foo".to_owned(), vec![None]), + ("bar".to_owned(), vec![None]) + ]), + } + ), HTML::from("bar, foo") ); assert_eq!( - render_all_leftovers(&Row { - label: "nope".to_owned(), - entries: HashMap::from([ - ("foo".to_owned(), vec![None]), - ("bar".to_owned(), vec![None, None]) - ]), - }), + render_all_leftovers( + &Config::default(), + &Row { + label: "nope".to_owned(), + entries: HashMap::from([ + ("foo".to_owned(), vec![None]), + ("bar".to_owned(), vec![None, None]) + ]), + } + ), HTML::from("bar: 2, foo") ); } -- 2.44.1