diff --git a/CHANGELOG.md b/CHANGELOG.md index 61947b3f7f..e7dd47f287 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ ## Other +- Fix Clippy lints, see #1661 (@mohamed-abdelnour) + ## Syntaxes diff --git a/src/assets.rs b/src/assets.rs index bac0c430d2..8850978852 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -201,7 +201,7 @@ impl HighlightingAssets { bat_warning!("Theme '{}' is deprecated, using 'ansi' instead.", theme); return self.get_theme("ansi"); } - if theme != "" { + if !theme.is_empty() { bat_warning!("Unknown theme '{}', using default.", theme) } &self.theme_set.themes[self.fallback_theme.unwrap_or_else(|| Self::default_theme())] diff --git a/src/pager.rs b/src/pager.rs index c6a4170d90..3473aa67da 100644 --- a/src/pager.rs +++ b/src/pager.rs @@ -98,17 +98,17 @@ pub(crate) fn get_pager(config_pager: Option<&str>) -> Result, Par Some((bin, args)) => { let kind = PagerKind::from_bin(bin); - let use_less_instead = match (&source, &kind) { - // 'more' and 'most' do not supports colors; automatically use 'less' instead - // if the problematic pager came from the generic PAGER env var - (PagerSource::EnvVarPager, PagerKind::More) => true, - (PagerSource::EnvVarPager, PagerKind::Most) => true, - - // If PAGER=bat, silently use 'less' instead to prevent recursion ... - (PagerSource::EnvVarPager, PagerKind::Bat) => true, - - // Never silently use less if BAT_PAGER or --pager has been specified - _ => false, + let use_less_instead = if source == PagerSource::EnvVarPager { + // 'more' and 'most' do not supports colors; automatically use + // 'less' instead if the problematic pager came from the + // generic PAGER env var. + // If PAGER=bat, silently use 'less' instead to prevent + // recursion. + // Never silently use 'less' if BAT_PAGER or --pager has been + // specified. + matches!(kind, PagerKind::More | PagerKind::Most | PagerKind::Bat) + } else { + false }; Ok(Some(if use_less_instead { diff --git a/src/pretty_printer.rs b/src/pretty_printer.rs index 7f1c2b7f34..f60c829d47 100644 --- a/src/pretty_printer.rs +++ b/src/pretty_printer.rs @@ -40,10 +40,11 @@ pub struct PrettyPrinter<'a> { impl<'a> PrettyPrinter<'a> { pub fn new() -> Self { - let mut config = Config::default(); - - config.colored_output = true; - config.true_color = true; + let config = Config { + colored_output: true, + true_color: true, + ..Default::default() + }; PrettyPrinter { inputs: vec![], @@ -335,14 +336,14 @@ impl<'a> Input<'a> { } } -impl<'a> Into> for input::Input<'a> { - fn into(self) -> Input<'a> { - Input { input: self } +impl<'a> From> for Input<'a> { + fn from(input: input::Input<'a>) -> Self { + Self { input } } } -impl<'a> Into> for Input<'a> { - fn into(self) -> input::Input<'a> { - self.input +impl<'a> From> for input::Input<'a> { + fn from(Input { input }: Input<'a>) -> Self { + input } } diff --git a/src/printer.rs b/src/printer.rs index 45caf15787..11db95636d 100644 --- a/src/printer.rs +++ b/src/printer.rs @@ -447,8 +447,10 @@ impl<'a> Printer for InteractivePrinter<'a> { if text.len() != text_trimmed.len() { if let Some(background_color) = background_color { - let mut ansi_style = Style::default(); - ansi_style.background = to_ansi_color(background_color, true_color); + let ansi_style = Style { + background: to_ansi_color(background_color, true_color), + ..Default::default() + }; let width = if cursor_total <= cursor_max { cursor_max - cursor_total + 1 } else { @@ -588,8 +590,10 @@ impl<'a> Printer for InteractivePrinter<'a> { } if let Some(background_color) = background_color { - let mut ansi_style = Style::default(); - ansi_style.background = to_ansi_color(background_color, self.config.true_color); + let ansi_style = Style { + background: to_ansi_color(background_color, self.config.true_color), + ..Default::default() + }; write!( handle,