From c6bf90ffeb4c78e075c3631f02a6c4806f2776c3 Mon Sep 17 00:00:00 2001 From: Catherine Noll Date: Sun, 13 Nov 2022 23:06:55 +0000 Subject: [PATCH] Fix clippy warnings --- src/features/line_numbers.rs | 4 ++-- src/handlers/blame.rs | 2 +- src/handlers/diff_header.rs | 10 ++++------ src/handlers/grep.rs | 2 +- src/subcommands/diff.rs | 2 +- src/subcommands/list_syntax_themes.rs | 6 +++--- src/utils/path.rs | 2 +- 7 files changed, 13 insertions(+), 15 deletions(-) diff --git a/src/features/line_numbers.rs b/src/features/line_numbers.rs index 888504340..d9ab79488 100644 --- a/src/features/line_numbers.rs +++ b/src/features/line_numbers.rs @@ -167,12 +167,12 @@ impl<'a> LineNumbersData<'a> { format_data: MinusPlus::new( format::parse_line_number_format( &format[Left], - &*LINE_NUMBERS_PLACEHOLDER_REGEX, + &LINE_NUMBERS_PLACEHOLDER_REGEX, false, ), format::parse_line_number_format( &format[Right], - &*LINE_NUMBERS_PLACEHOLDER_REGEX, + &LINE_NUMBERS_PLACEHOLDER_REGEX, insert_center_space_on_odd_width, ), ), diff --git a/src/handlers/blame.rs b/src/handlers/blame.rs index 0e21f6bc6..a1ec97b8d 100644 --- a/src/handlers/blame.rs +++ b/src/handlers/blame.rs @@ -43,7 +43,7 @@ impl<'a> StateMachine<'a> { // Format blame metadata let format_data = format::parse_line_number_format( &self.config.blame_format, - &*BLAME_PLACEHOLDER_REGEX, + &BLAME_PLACEHOLDER_REGEX, false, ); let mut formatted_blame_metadata = diff --git a/src/handlers/diff_header.rs b/src/handlers/diff_header.rs index 5038efd5b..75763b829 100644 --- a/src/handlers/diff_header.rs +++ b/src/handlers/diff_header.rs @@ -88,7 +88,7 @@ impl<'a> StateMachine<'a> { parse_diff_header_line(&self.line, self.source == Source::GitDiff); self.minus_file = utils::path::relativize_path_maybe(&path_or_mode, self.config) - .map(|p| p.to_string_lossy().to_owned().to_string()) + .map(|p| p.to_string_lossy().into_owned()) .unwrap_or(path_or_mode); self.minus_file_event = file_event; @@ -125,7 +125,7 @@ impl<'a> StateMachine<'a> { parse_diff_header_line(&self.line, self.source == Source::GitDiff); self.plus_file = utils::path::relativize_path_maybe(&path_or_mode, self.config) - .map(|p| p.to_string_lossy().to_owned().to_string()) + .map(|p| p.to_string_lossy().into_owned()) .unwrap_or(path_or_mode); self.plus_file_event = file_event; self.painter @@ -162,8 +162,7 @@ impl<'a> StateMachine<'a> { let mut handled_line = false; let (_mode_info, file_event) = parse_diff_header_line(&self.line, self.source == Source::GitDiff); - let name = get_repeated_file_path_from_diff_line(&self.diff_line) - .unwrap_or_else(|| "".to_string()); + let name = get_repeated_file_path_from_diff_line(&self.diff_line).unwrap_or_default(); match file_event { FileEvent::Removed => { self.minus_file = name; @@ -242,8 +241,7 @@ impl<'a> StateMachine<'a> { _ => Cow::from(file), }; let label = format_label(&self.config.file_modified_label); - let name = get_repeated_file_path_from_diff_line(&self.diff_line) - .unwrap_or_else(|| "".to_string()); + let name = get_repeated_file_path_from_diff_line(&self.diff_line).unwrap_or_default(); let line = format!("{}{}", label, format_file(&name)); write_generic_diff_header_header_line( &line, diff --git a/src/handlers/grep.rs b/src/handlers/grep.rs index 986de3863..2eadd1f3a 100644 --- a/src/handlers/grep.rs +++ b/src/handlers/grep.rs @@ -439,7 +439,7 @@ pub fn parse_grep_line(line: &str) -> Option { &*GREP_LINE_REGEX_ASSUMING_NO_INTERNAL_SEPARATOR_CHARS, ] .iter() - .find_map(|regex| _parse_grep_line(*regex, line)), + .find_map(|regex| _parse_grep_line(regex, line)), _ => None, } } diff --git a/src/subcommands/diff.rs b/src/subcommands/diff.rs index 6c7fbf004..30d4e64bd 100644 --- a/src/subcommands/diff.rs +++ b/src/subcommands/diff.rs @@ -40,7 +40,7 @@ pub fn diff( let diff_process = process::Command::new(diff_path) .args(&diff_cmd[1..]) - .args(&[minus_file, plus_file]) + .args([minus_file, plus_file]) .stdout(process::Stdio::piped()) .spawn(); diff --git a/src/subcommands/list_syntax_themes.rs b/src/subcommands/list_syntax_themes.rs index 34a7b0b49..e8bdc3193 100644 --- a/src/subcommands/list_syntax_themes.rs +++ b/src/subcommands/list_syntax_themes.rs @@ -19,11 +19,11 @@ pub fn _list_syntax_themes_for_humans(writer: &mut dyn Write) -> std::io::Result let assets = utils::bat::assets::load_highlighting_assets(); writeln!(writer, "Light syntax themes:")?; - for theme in assets.themes().filter(|t| is_light_syntax_theme(*t)) { + for theme in assets.themes().filter(|t| is_light_syntax_theme(t)) { writeln!(writer, " {}", theme)?; } writeln!(writer, "\nDark syntax themes:")?; - for theme in assets.themes().filter(|t| !is_light_syntax_theme(*t)) { + for theme in assets.themes().filter(|t| !is_light_syntax_theme(t)) { writeln!(writer, " {}", theme)?; } writeln!( @@ -35,7 +35,7 @@ pub fn _list_syntax_themes_for_humans(writer: &mut dyn Write) -> std::io::Result pub fn _list_syntax_themes_for_machines(writer: &mut dyn Write) -> std::io::Result<()> { let assets = utils::bat::assets::load_highlighting_assets(); - for theme in assets.themes().sorted_by_key(|t| is_light_syntax_theme(*t)) { + for theme in assets.themes().sorted_by_key(|t| is_light_syntax_theme(t)) { writeln!( writer, "{}\t{}", diff --git a/src/utils/path.rs b/src/utils/path.rs index 6891e81a8..524ef910b 100644 --- a/src/utils/path.rs +++ b/src/utils/path.rs @@ -29,7 +29,7 @@ pub fn absolute_path(relative_path: &str, config: &Config) -> Option { pub fn relativize_path_maybe(path: &str, config: &Config) -> Option { if config.relative_paths && !calling_process().paths_in_input_are_relative_to_cwd() { if let Some(base) = config.cwd_relative_to_repo_root.as_deref() { - pathdiff::diff_paths(&path, base) + pathdiff::diff_paths(path, base) } else { None }