diff options
| author | Anthony Rubick <68485672+AnthonyMichaelTDM@users.noreply.github.com> | 2023-07-09 20:07:09 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-07-10 11:07:09 +0800 |
| commit | 97fc7de6754c8b5c383d7d5e3f9e26b3bbfb08fb (patch) | |
| tree | c19390877425fa50049761e8ee6bc93f21c46f56 /src/repl/highlighter.rs | |
| parent | ec51b84290215d11d5045de8baa9b89f2447b1e9 (diff) | |
| download | aichat-97fc7de6754c8b5c383d7d5e3f9e26b3bbfb08fb.tar.gz | |
fix: minor code cleanup and pedantic lints (#134)
Diffstat (limited to 'src/repl/highlighter.rs')
| -rw-r--r-- | src/repl/highlighter.rs | 14 |
1 files changed, 8 insertions, 6 deletions
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<String>, 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<String>) -> ReplHighlighter { + pub fn new(config: SharedConfig, external_commands: Vec<String>) -> 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 { |
