]> git.scottworley.com Git - tablify/commitdiff
Appease clippy::pattern_type_mismatch
authorScott Worley <scottworley@scottworley.com>
Wed, 16 Jul 2025 10:16:51 +0000 (03:16 -0700)
committerScott Worley <scottworley@scottworley.com>
Wed, 16 Jul 2025 10:16:51 +0000 (03:16 -0700)
src/lib.rs

index ac52b1fb61f184ae0f7c4dd48592e832311e52a5..23667a1be543bd141b3d179e945ee477a33f26d7 100644 (file)
@@ -224,7 +224,7 @@ impl<Input: Iterator<Item = Result<String, std::io::Error>>> Iterator for Reader
                         return Ok(std::mem::take(&mut self.row).map(Rowlike::Row)).transpose()
                     }
                     InputLine::Blank => return Some(Ok(Rowlike::Spacer)),
-                    InputLine::Entry(col, instance) => match &mut self.row {
+                    InputLine::Entry(col, instance) => match self.row {
                         None => {
                             return Some(Err(std::io::Error::other(format!(
                                 "line {}: Entry with no header",
@@ -266,8 +266,8 @@ fn column_counts(rows: &[Rowlike]) -> Vec<(usize, String)> {
     let empty = HashMap::new();
     let mut counts: Vec<_> = rows
         .iter()
-        .flat_map(|rl| match rl {
-            Rowlike::Row(r) => r.entries.keys(),
+        .flat_map(|rl| match *rl {
+            Rowlike::Row(ref r) => r.entries.keys(),
             Rowlike::Spacer => empty.keys(),
         })
         .fold(HashMap::new(), |mut cs, col| {
@@ -279,7 +279,7 @@ fn column_counts(rows: &[Rowlike]) -> Vec<(usize, String)> {
         .into_iter()
         .map(|(col, n)| (n, col))
         .collect();
-    counts.sort_unstable_by(|(an, acol), (bn, bcol)| bn.cmp(an).then(acol.cmp(bcol)));
+    counts.sort_unstable_by(|a, b| b.0.cmp(&a.0).then(a.1.cmp(&b.1)));
     counts
 }
 fn column_order(config: &Config, rows: &[Rowlike]) -> Vec<String> {
@@ -304,9 +304,9 @@ fn render_instances(instances: &[Option<String>], mark: Option<&str>) -> HTML {
     let mut tally = 0;
     let mut out = vec![];
     for ins in instances {
-        match ins {
+        match *ins {
             None => tally += 1,
-            Some(content) => {
+            Some(ref content) => {
                 if tally > 0 {
                     out.push(HTML(tally_marks(tally, mark)));
                     tally = 0;
@@ -337,9 +337,9 @@ fn render_cell(config: &Config, col: &str, row: &mut Row) -> HTML {
     let instances: Option<&Vec<Option<String>>> = row.entries.get(col);
     let is_empty = match instances {
         None => true,
-        Some(is) => is.iter().all(|ins| match ins {
+        Some(is) => is.iter().all(|ins| match *ins {
             None => false,
-            Some(content) => content == "×",
+            Some(ref content) => content == "×",
         }),
     };
     let class = HTML::from(if is_empty { "" } else { r#" class="yes""# });
@@ -387,16 +387,16 @@ fn render_all_leftovers(config: &Config, row: &Row) -> HTML {
 }
 
 fn render_row(config: &Config, columns: &[String], rowlike: &mut Rowlike) -> HTML {
-    match rowlike {
+    match *rowlike {
         Rowlike::Spacer => HTML::from("<tr><th class=\"spacer_row\"></th></tr>\n"),
-        Rowlike::Row(row) => {
+        Rowlike::Row(ref mut row) => {
             let row_label = HTML::escape(row.label.as_ref());
             let static_cells = config
                 .static_columns
                 .iter()
-                .map(|ocol| match ocol {
-                    Some(col) if config.hidden_columns.contains(col) => HTML::from(""),
-                    Some(col) => render_cell(config, col, row),
+                .map(|ocol| match *ocol {
+                    Some(ref col) if config.hidden_columns.contains(col) => HTML::from(""),
+                    Some(ref col) => render_cell(config, col, row),
                     None => HTML::from(r#"<td class="spacer_col"></td>"#),
                 })
                 .collect::<HTML>();