From 97fc7de6754c8b5c383d7d5e3f9e26b3bbfb08fb Mon Sep 17 00:00:00 2001 From: Anthony Rubick <68485672+AnthonyMichaelTDM@users.noreply.github.com> Date: Sun, 9 Jul 2023 20:07:09 -0700 Subject: fix: minor code cleanup and pedantic lints (#134) --- src/repl/highlighter.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/repl/highlighter.rs') diff --git a/src/repl/highlighter.rs b/src/repl/highlighter.rs index 593c307..b1ec023 100644 --- a/src/repl/highlighter.rs +++ b/src/repl/highlighter.rs @@ -5,6 +5,7 @@ use reedline::{Highlighter, StyledText}; const MATCH_COLOR: Color = Color::Green; +#[allow(clippy::module_name_repetitions)] pub struct ReplHighlighter { external_commands: Vec, config: SharedConfig, @@ -12,10 +13,10 @@ pub struct ReplHighlighter { impl ReplHighlighter { /// Construct the default highlighter with a given set of extern commands/keywords to detect and highlight - pub fn new(config: SharedConfig, external_commands: Vec) -> ReplHighlighter { + pub fn new(config: SharedConfig, external_commands: Vec) -> Self { Self { - config, external_commands, + config, } } } @@ -28,9 +29,10 @@ impl Highlighter for ReplHighlighter { } else { Color::White }; - let match_color = match self.config.read().highlight { - true => MATCH_COLOR, - false => color, + let match_color = if self.config.read().highlight { + MATCH_COLOR + } else { + color }; if self @@ -45,7 +47,7 @@ impl Highlighter for ReplHighlighter { .filter(|c| line.contains(*c)) .map(std::ops::Deref::deref) .collect(); - let longest_match = matches.iter().fold("".to_string(), |acc, &item| { + let longest_match = matches.iter().fold(String::new(), |acc, &item| { if item.len() > acc.len() { item.to_string() } else { -- cgit v1.2.3