From f08cf307c6973eec1e64f2410cfcf70c61d604da Mon Sep 17 00:00:00 2001 From: graelo Date: Sat, 10 Dec 2022 15:58:44 +0100 Subject: [PATCH] chore(clippy): fix warnings from nightly --- src/bin/copyrat.rs | 2 +- src/textbuf/alphabet.rs | 2 +- src/tmux.rs | 4 ++-- src/ui/colors.rs | 4 ++-- src/ui/vc.rs | 20 +++----------------- 5 files changed, 9 insertions(+), 23 deletions(-) diff --git a/src/bin/copyrat.rs b/src/bin/copyrat.rs index f0ad7d4..254db50 100644 --- a/src/bin/copyrat.rs +++ b/src/bin/copyrat.rs @@ -24,5 +24,5 @@ fn main() { } let Selection { text, .. } = selection.unwrap(); - println!("{}", text); + println!("{text}"); } diff --git a/src/textbuf/alphabet.rs b/src/textbuf/alphabet.rs index f24a97a..577f0f7 100644 --- a/src/textbuf/alphabet.rs +++ b/src/textbuf/alphabet.rs @@ -114,7 +114,7 @@ impl Alphabet { let gen: Vec = letters .iter() .take(n - lead.len() - prev.len()) - .map(|c| format!("{}{}", prefix, c)) + .map(|c| format!("{prefix}{c}")) .collect(); // Insert gen in front of prev diff --git a/src/tmux.rs b/src/tmux.rs index cad5450..6346e7d 100644 --- a/src/tmux.rs +++ b/src/tmux.rs @@ -141,7 +141,7 @@ impl FromStr for PaneId { return Err(Error::ExpectedPaneIdMarker); } let id = src[1..].parse::()?; - let id = format!("%{}", id); + let id = format!("%{id}"); Ok(PaneId(id)) } } @@ -189,7 +189,7 @@ pub fn get_options(prefix: &str) -> Result> { let output = duct::cmd!("tmux", "show-options", "-g").read()?; let lines: Vec<&str> = output.split('\n').collect(); - let pattern = format!(r#"({prefix}[\w\-0-9]+) "?(\w+)"?"#, prefix = prefix); + let pattern = format!(r#"({prefix}[\w\-0-9]+) "?(\w+)"?"#); let re = Regex::new(&pattern).unwrap(); let args: HashMap = lines diff --git a/src/ui/colors.rs b/src/ui/colors.rs index 3be3d1b..d21cad1 100644 --- a/src/ui/colors.rs +++ b/src/ui/colors.rs @@ -13,7 +13,7 @@ impl tcolor::Color for Color { #[inline] fn write_fg(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.0 { - Some(value) => write!(f, "\x1B[38;5;{}m", value), + Some(value) => write!(f, "\x1B[38;5;{value}m"), None => write!(f, "\x1B[39m"), } } @@ -21,7 +21,7 @@ impl tcolor::Color for Color { #[inline] fn write_bg(&self, f: &mut fmt::Formatter) -> fmt::Result { match self.0 { - Some(value) => write!(f, "\x1B[48;5;{}m", value), + Some(value) => write!(f, "\x1B[48;5;{value}m"), None => write!(f, "\x1B[49m"), } } diff --git a/src/ui/vc.rs b/src/ui/vc.rs index c81c644..747a1cc 100644 --- a/src/ui/vc.rs +++ b/src/ui/vc.rs @@ -271,13 +271,7 @@ impl<'a> ViewController<'a> { None => { write!( stdout, - "{goto}{bg_color}{fg_color}{hint}{fg_reset}{bg_reset}", - goto = goto, - fg_color = fg_color, - bg_color = bg_color, - fg_reset = fg_reset, - bg_reset = bg_reset, - hint = hint_text, + "{goto}{bg_color}{fg_color}{hint_text}{fg_reset}{bg_reset}", ) .unwrap(); } @@ -330,15 +324,7 @@ impl<'a> ViewController<'a> { HintStyle::Surround(opening, closing) => { write!( stdout, - "{goto}{bg_color}{fg_color}{bra}{hint}{bra_close}{fg_reset}{bg_reset}", - goto = goto, - fg_color = fg_color, - bg_color = bg_color, - fg_reset = fg_reset, - bg_reset = bg_reset, - bra = opening, - bra_close = closing, - hint = hint_text, + "{goto}{bg_color}{fg_color}{opening}{hint_text}{closing}{fg_reset}{bg_reset}", ) .unwrap(); } @@ -531,7 +517,7 @@ impl<'a> ViewController<'a> { event::Key::Char(_ch @ ' ') => { output_destination.toggle(); - let message = format!("output destination: `{}`", output_destination); + let message = format!("output destination: `{output_destination}`"); duct::cmd!("tmux", "display-message", &message) .run() .expect("could not make tmux display the message.");