From c7a4cb4f24401b0f3bc73dea2ba7a72f417fc76a Mon Sep 17 00:00:00 2001 From: Akiomi Kamakura Date: Thu, 13 Jun 2024 05:01:07 +0900 Subject: [PATCH] Fix for cargo clippy (#404) --- json_to_table/src/table/collapsed_table.rs | 6 ++++++ papergrid/src/config/spanned/mod.rs | 4 ++-- tabled/src/settings/merge/mod.rs | 6 ++++++ tabled/src/settings/width/truncate.rs | 2 +- tabled/src/tables/table_pool.rs | 19 +++++++++++++++++++ 5 files changed, 34 insertions(+), 3 deletions(-) diff --git a/json_to_table/src/table/collapsed_table.rs b/json_to_table/src/table/collapsed_table.rs index bbc88710..8136ee52 100644 --- a/json_to_table/src/table/collapsed_table.rs +++ b/json_to_table/src/table/collapsed_table.rs @@ -585,6 +585,7 @@ fn generate_value_cell(value: &str, cfg: &Config, ctx: PrintContext) -> CellData CellData::new(table, vec![ctx.size.width], vec![ctx.size.height]) } +#[allow(dead_code)] struct NoTopBorders; impl TableOption for NoTopBorders { @@ -627,6 +628,7 @@ impl TableOption for NoRightBorders { } } +#[allow(dead_code)] struct NoLeftBorders; impl TableOption for NoLeftBorders { @@ -685,6 +687,7 @@ impl TableOption for TopRightChangeToRight { } } +#[allow(dead_code)] struct BottomLeftChangeSplit; impl TableOption for BottomLeftChangeSplit { @@ -696,6 +699,7 @@ impl TableOption for BottomLeftChangeSplit { } } +#[allow(dead_code)] struct BottomLeftChangeSplitToIntersection; impl TableOption for BottomLeftChangeSplitToIntersection { @@ -707,6 +711,7 @@ impl TableOption for BottomLeftChangeSplitToIntersect } } +#[allow(dead_code)] struct BottomRightChangeToRight; impl TableOption for BottomRightChangeToRight { @@ -729,6 +734,7 @@ impl TableOption for BottomLeftChangeToBottomIntersec } } +#[allow(dead_code)] struct SetBottomChars<'a>(&'a [usize], char); impl TableOption for SetBottomChars<'_> diff --git a/papergrid/src/config/spanned/mod.rs b/papergrid/src/config/spanned/mod.rs index 2266a8b9..69ad194e 100644 --- a/papergrid/src/config/spanned/mod.rs +++ b/papergrid/src/config/spanned/mod.rs @@ -282,7 +282,7 @@ impl SpannedConfig { /// It takes not cell position but line as row and column of a cell; /// So its range is line <= count_rows && col < count_columns. pub fn is_overridden_horizontal(&self, pos: Position) -> bool { - self.horizontal_chars.get(&pos).is_some() + self.horizontal_chars.contains_key(&pos) } /// Removes a list of overridden chars in a horizontal border. @@ -336,7 +336,7 @@ impl SpannedConfig { /// It takes not cell position but cell row and column of a line; /// So its range is row < count_rows && col <= count_columns. pub fn is_overridden_vertical(&self, pos: Position) -> bool { - self.vertical_chars.get(&pos).is_some() + self.vertical_chars.contains_key(&pos) } /// Removes a list of overridden chars in a horizontal border. diff --git a/tabled/src/settings/merge/mod.rs b/tabled/src/settings/merge/mod.rs index ffc9d205..1e1ea7a8 100644 --- a/tabled/src/settings/merge/mod.rs +++ b/tabled/src/settings/merge/mod.rs @@ -38,6 +38,9 @@ impl TableOption for MergeDuplicatesVertical where R: Records + PeekableRecords + ExactRecords, { + #[allow(clippy::assigning_clones)] + // NOTE: Temporarily disabled due to a issue with `assigning_clones` not respecting MSRV in clippy 1.78.0. + // See https://github.com/rust-lang/rust-clippy/issues/12502 fn change(self, records: &mut R, cfg: &mut ColoredConfig, _: &mut D) { let count_rows = records.count_rows(); let count_cols = records.count_columns(); @@ -122,6 +125,9 @@ impl TableOption for MergeDuplicatesHorizontal where R: Records + PeekableRecords + ExactRecords, { + #[allow(clippy::assigning_clones)] + // NOTE: Temporarily disabled due to a issue with `assigning_clones` not respecting MSRV in clippy 1.78.0. + // See https://github.com/rust-lang/rust-clippy/issues/12502 fn change(self, records: &mut R, cfg: &mut ColoredConfig, _: &mut D) { let count_rows = records.count_rows(); let count_cols = records.count_columns(); diff --git a/tabled/src/settings/width/truncate.rs b/tabled/src/settings/width/truncate.rs index ef31234e..3fcf1d4a 100644 --- a/tabled/src/settings/width/truncate.rs +++ b/tabled/src/settings/width/truncate.rs @@ -371,7 +371,7 @@ where for ((row, col), width) in points { let mut truncate = Truncate::new(width); - truncate.suffix = suffix.clone(); + truncate.suffix.clone_from(&suffix); truncate.multiline = multiline; CellOption::change(truncate, records, cfg, (row, col).into()); } diff --git a/tabled/src/tables/table_pool.rs b/tabled/src/tables/table_pool.rs index 2891e0c8..fc315bf1 100644 --- a/tabled/src/tables/table_pool.rs +++ b/tabled/src/tables/table_pool.rs @@ -984,6 +984,7 @@ mod print { } } + #[allow(dead_code)] struct ConfigCell(PrintContext); impl TableOption for ConfigCell { @@ -1097,6 +1098,7 @@ mod print { borders.vertical = None; } + #[allow(dead_code)] fn cfg_set_top_chars(cfg: &mut ColoredConfig, list: &[usize], c: char) { for &split in list { let offset = split; @@ -1104,12 +1106,14 @@ mod print { } } + #[allow(dead_code)] fn cfg_set_left_chars(cfg: &mut ColoredConfig, list: &[usize], c: char) { for &offset in list { cfg.set_vertical_char((0, 0), c, Offset::Begin(offset)); } } + #[allow(dead_code)] struct NoTopBorders; impl TableOption for NoTopBorders { @@ -1124,6 +1128,7 @@ mod print { } } + #[allow(dead_code)] struct NoBottomBorders; impl TableOption for NoBottomBorders { @@ -1138,6 +1143,7 @@ mod print { } } + #[allow(dead_code)] struct NoRightBorders; impl TableOption for NoRightBorders { @@ -1152,6 +1158,7 @@ mod print { } } + #[allow(dead_code)] struct NoLeftBorders; impl TableOption for NoLeftBorders { @@ -1166,6 +1173,7 @@ mod print { } } + #[allow(dead_code)] struct TopLeftChangeTopIntersection; impl TableOption for TopLeftChangeTopIntersection { @@ -1177,6 +1185,7 @@ mod print { } } + #[allow(dead_code)] struct TopLeftChangeIntersection; impl TableOption for TopLeftChangeIntersection { @@ -1188,6 +1197,7 @@ mod print { } } + #[allow(dead_code)] struct TopLeftChangeToLeft; impl TableOption for TopLeftChangeToLeft { @@ -1199,6 +1209,7 @@ mod print { } } + #[allow(dead_code)] struct TopRightChangeToRight; impl TableOption for TopRightChangeToRight { @@ -1210,6 +1221,7 @@ mod print { } } + #[allow(dead_code)] struct BottomLeftChangeSplit; impl TableOption for BottomLeftChangeSplit { @@ -1221,6 +1233,7 @@ mod print { } } + #[allow(dead_code)] struct BottomLeftChangeSplitToIntersection; impl TableOption for BottomLeftChangeSplitToIntersection { @@ -1232,6 +1245,7 @@ mod print { } } + #[allow(dead_code)] struct BottomRightChangeToRight; impl TableOption for BottomRightChangeToRight { @@ -1243,6 +1257,7 @@ mod print { } } + #[allow(dead_code)] struct BottomLeftChangeToBottomIntersection; impl TableOption for BottomLeftChangeToBottomIntersection { @@ -1254,6 +1269,7 @@ mod print { } } + #[allow(dead_code)] struct SetBottomChars<'a>(&'a [usize], char); impl TableOption for SetBottomChars<'_> @@ -1285,6 +1301,7 @@ mod print { } } + #[allow(dead_code)] struct SetTopChars<'a>(&'a [usize], char); impl TableOption for SetTopChars<'_> { @@ -1296,6 +1313,7 @@ mod print { } } + #[allow(dead_code)] struct SetLeftChars<'a>(&'a [usize], char); impl TableOption for SetLeftChars<'_> { @@ -1614,6 +1632,7 @@ mod print { ) } + #[allow(dead_code)] fn cfg_clear_borders(cfg: &mut ColoredConfig) { cfg.remove_borders(); cfg.remove_borders_colors();