diff --git a/build.rs b/build.rs index 06bb6863..3c7083e6 100644 --- a/build.rs +++ b/build.rs @@ -68,8 +68,7 @@ fn write_command( output .write( format!( - " commands.insert(\"{}::{}\", {}::{});\n", - module_name, function_name, module_name, function_name + " commands.insert(\"{module_name}::{function_name}\", {module_name}::{function_name});\n" ) .as_bytes(), ) diff --git a/src/commands/application.rs b/src/commands/application.rs index cc8ebc6a..d9e60b4b 100644 --- a/src/commands/application.rs +++ b/src/commands/application.rs @@ -275,7 +275,7 @@ pub fn display_available_commands(app: &mut Application) -> Result { command_keys.sort(); command_keys.reverse(); for key in command_keys { - buffer.insert(format!("{}\n", key)); + buffer.insert(format!("{key}\n")); } } @@ -287,11 +287,11 @@ pub fn display_last_error(app: &mut Application) -> Result { let scope_display_buffer = { let mut error_buffer = Buffer::new(); // Add the proximate/contextual error. - error_buffer.insert(format!("{}\n", error)); + error_buffer.insert(format!("{error}\n")); // Print the chain of other errors that led to the proximate error. for err in error.iter().skip(1) { - error_buffer.insert(format!("caused by: {}", err)); + error_buffer.insert(format!("caused by: {err}")); } error_buffer diff --git a/src/commands/buffer.rs b/src/commands/buffer.rs index 316fe704..ae552fd4 100644 --- a/src/commands/buffer.rs +++ b/src/commands/buffer.rs @@ -142,7 +142,7 @@ pub fn merge_next_line(app: &mut Application) -> Result { .take(2) .map(|(index, line)| { if index == current_line { - format!("{} ", line) + format!("{line} ") } else { line.trim_start().to_string() } @@ -357,7 +357,7 @@ pub fn display_current_scope(app: &mut Application) -> Result { // Open a buffer with a displayable version of the scope stack. let mut scope_display_buffer = Buffer::new(); for scope in scope_stack.iter() { - scope_display_buffer.insert(format!("{}\n", scope)); + scope_display_buffer.insert(format!("{scope}\n")); } scope_display_buffer @@ -761,7 +761,7 @@ pub fn paste(app: &mut Application) -> Result { line, offset: line_content.len(), }); - buffer.insert(format!("\n{}", content)); + buffer.insert(format!("\n{content}")); buffer.cursor.move_to(original_cursor_position); } else { // We're on a trailing newline, which doesn't diff --git a/src/commands/git.rs b/src/commands/git.rs index d3b400e4..e1ce1680 100644 --- a/src/commands/git.rs +++ b/src/commands/git.rs @@ -80,9 +80,9 @@ pub fn copy_remote_url(app: &mut Application) -> Result { let line_2 = s.anchor + 1; match line_1.cmp(&line_2) { - Ordering::Less => format!("#L{}-L{}", line_1, line_2), - Ordering::Greater => format!("#L{}-L{}", line_2, line_1), - Ordering::Equal => format!("#L{}", line_1), + Ordering::Less => format!("#L{line_1}-L{line_2}"), + Ordering::Greater => format!("#L{line_2}-L{line_1}"), + Ordering::Equal => format!("#L{line_1}"), } } _ => String::new(), diff --git a/src/commands/search.rs b/src/commands/search.rs index 72d88d8e..c24b033d 100644 --- a/src/commands/search.rs +++ b/src/commands/search.rs @@ -44,7 +44,7 @@ pub fn move_to_current_result(app: &mut Application) -> Result { .as_mut() .ok_or(NO_SEARCH_RESULTS)? .selection() - .ok_or_else(|| format!("No matches found for \"{}\"", query))?; + .ok_or_else(|| format!("No matches found for \"{query}\""))?; buffer.cursor.move_to(result.start()); } else { bail!("Can't move to search result outside of search mode"); diff --git a/src/input/key_map/mod.rs b/src/input/key_map/mod.rs index 3f754df6..a8107de2 100644 --- a/src/input/key_map/mod.rs +++ b/src/input/key_map/mod.rs @@ -31,7 +31,7 @@ impl KeyMap { .as_str() .ok_or_else(|| "A mode key couldn't be parsed as a string".to_string())?; let key_bindings = parse_mode_key_bindings(yaml_key_bindings, &commands) - .chain_err(|| format!("Failed to parse keymaps for \"{}\" mode", mode))?; + .chain_err(|| format!("Failed to parse keymaps for \"{mode}\" mode"))?; keymap.insert(mode.to_string(), key_bindings); } @@ -146,21 +146,20 @@ fn parse_mode_key_bindings( Yaml::String(ref command) => { let command_string = command.as_str(); - key_commands.push(*commands.get(&command_string).ok_or_else(|| { - format!("Keymap command \"{}\" doesn't exist", command_string) - })?); + key_commands.push( + *commands.get(&command_string).ok_or_else(|| { + format!("Keymap command \"{command_string}\" doesn't exist") + })?, + ); } Yaml::Array(ref command_array) => { for command in command_array { let command_string = command.as_str().ok_or_else(|| { - format!( - "Keymap command \"{:?}\" couldn't be parsed as a string", - command - ) + format!("Keymap command \"{command:?}\" couldn't be parsed as a string") })?; key_commands.push(*commands.get(command_string).ok_or_else(|| { - format!("Keymap command \"{}\" doesn't exist", command_string) + format!("Keymap command \"{command_string}\" doesn't exist") })?); } } @@ -194,7 +193,7 @@ fn parse_key(data: &str) -> Result { let key_char = key .chars() .next() - .ok_or_else(|| format!("Keymap key \"{}\" is invalid", key))?; + .ok_or_else(|| format!("Keymap key \"{key}\" is invalid"))?; // Find the variant for the specified modifier. match component { @@ -225,7 +224,7 @@ fn parse_key(data: &str) -> Result { component .chars() .next() - .ok_or_else(|| format!("Keymap key \"{}\" is invalid", component))?, + .ok_or_else(|| format!("Keymap key \"{component}\" is invalid"))?, ), }) } diff --git a/src/main.rs b/src/main.rs index 720fcab9..31b1c40b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -13,16 +13,16 @@ fn main() { fn handle_error(error: &Error) { // Print the proximate/contextual error. - eprintln!("error: {}", error); + eprintln!("error: {error}"); // Print the chain of other errors that led to the proximate error. for e in error.iter().skip(1) { - eprintln!("caused by: {}", e); + eprintln!("caused by: {e}"); } // Print the backtrace, if available. if let Some(backtrace) = error.backtrace() { - eprintln!("backtrace: {:?}", backtrace); + eprintln!("backtrace: {backtrace:?}"); } // Exit with an error code. diff --git a/src/models/application/modes/open/exclusions.rs b/src/models/application/modes/open/exclusions.rs index ff2a1222..c46d21d5 100644 --- a/src/models/application/modes/open/exclusions.rs +++ b/src/models/application/modes/open/exclusions.rs @@ -9,7 +9,7 @@ pub fn parse(exclusion_data: &[Yaml]) -> Result> { if let Yaml::String(ref pattern) = *exclusion { mapped_exclusions.push( ExclusionPattern::new(pattern) - .chain_err(|| format!("Failed to parse exclusion pattern: {}", pattern))?, + .chain_err(|| format!("Failed to parse exclusion pattern: {pattern}"))?, ); } else { bail!("Found a non-string exclusion that can't be parsed."); diff --git a/src/presenters/modes/open.rs b/src/presenters/modes/open.rs index 8cbdca9e..2e558335 100644 --- a/src/presenters/modes/open.rs +++ b/src/presenters/modes/open.rs @@ -23,7 +23,7 @@ pub fn display(workspace: &mut Workspace, mode: &mut OpenMode, view: &mut View) presenter.print_status_line(&[ StatusLineData { - content: format!(" {} ", mode), + content: format!(" {mode} "), style: Style::Default, colors: Colors::Inverted, }, @@ -45,11 +45,11 @@ pub fn display(workspace: &mut Workspace, mode: &mut OpenMode, view: &mut View) for (line, result) in mode.results().enumerate() { let (content, colors, style) = if line == mode.selected_index() { - (format!("> {}", result), Colors::Focused, Style::Bold) + (format!("> {result}"), Colors::Focused, Style::Bold) } else if selected_indices.contains(&line) { - (format!(" {}", result), Colors::Focused, Style::Bold) + (format!(" {result}"), Colors::Focused, Style::Bold) } else { - (format!(" {}", result), Colors::Default, Style::Default) + (format!(" {result}"), Colors::Default, Style::Default) }; // Ensure content doesn't exceed the screen width diff --git a/src/presenters/modes/path.rs b/src/presenters/modes/path.rs index 2ad81731..c20df4f9 100644 --- a/src/presenters/modes/path.rs +++ b/src/presenters/modes/path.rs @@ -13,7 +13,7 @@ pub fn display(workspace: &mut Workspace, mode: &PathMode, view: &mut View) -> R let data = buffer.data(); presenter.print_buffer(buffer, &data, &workspace.syntax_set, None, None)?; - let mode_display = format!(" {} ", mode); + let mode_display = format!(" {mode} "); let search_input = format!(" {}", mode.input); let cursor_offset = mode_display.graphemes(true).count() + search_input.graphemes(true).count(); diff --git a/src/presenters/modes/search.rs b/src/presenters/modes/search.rs index 1a27ebd2..42834535 100644 --- a/src/presenters/modes/search.rs +++ b/src/presenters/modes/search.rs @@ -19,7 +19,7 @@ pub fn display(workspace: &mut Workspace, mode: &SearchMode, view: &mut View) -> None, )?; - let mode_display = format!(" {} ", mode); + let mode_display = format!(" {mode} "); let search_input = format!(" {}", mode.input.as_ref().unwrap_or(&String::new())); let result_display = if mode.insert { String::new() diff --git a/src/presenters/modes/search_select.rs b/src/presenters/modes/search_select.rs index 7c048def..80aabbb4 100644 --- a/src/presenters/modes/search_select.rs +++ b/src/presenters/modes/search_select.rs @@ -28,7 +28,7 @@ pub fn display( presenter.print_status_line(&[ StatusLineData { - content: format!(" {} ", mode), + content: format!(" {mode} "), style: Style::Default, colors: Colors::Inverted, }, @@ -48,9 +48,9 @@ pub fn display( // Draw the list of search results. for (line, result) in mode.results().enumerate() { let (content, colors, style) = if line == mode.selected_index() { - (format!("> {}", result), Colors::Focused, Style::Bold) + (format!("> {result}"), Colors::Focused, Style::Bold) } else { - (format!(" {}", result), Colors::Default, Style::Default) + (format!(" {result}"), Colors::Default, Style::Default) }; // Ensure content doesn't exceed the screen width diff --git a/src/view/presenter.rs b/src/view/presenter.rs index 3fb2c96f..a35da944 100644 --- a/src/view/presenter.rs +++ b/src/view/presenter.rs @@ -31,7 +31,7 @@ impl<'p> Presenter<'p> { .theme_set .themes .get(theme_name) - .ok_or_else(|| format!("Couldn't find \"{}\" theme", theme_name))?; + .ok_or_else(|| format!("Couldn't find \"{theme_name}\" theme"))?; theme.clone() }; diff --git a/src/view/terminal/termion_terminal.rs b/src/view/terminal/termion_terminal.rs index 72db3524..ec2dd7c4 100644 --- a/src/view/terminal/termion_terminal.rs +++ b/src/view/terminal/termion_terminal.rs @@ -70,7 +70,7 @@ impl TermionTerminal { // Adding new styles are easy; write it and return early. if let Some(mapped_style) = map_style(new_style) { - let _ = write!(output, "{}", mapped_style); + let _ = write!(output, "{mapped_style}"); return Ok(()); } @@ -293,7 +293,7 @@ impl Terminal for TermionTerminal { // Now that style, color, and position have been // addressed, print the content. - let _ = write!(output, "{}", content); + let _ = write!(output, "{content}"); } } diff --git a/src/view/terminal/test_terminal.rs b/src/view/terminal/test_terminal.rs index 3556fed8..86736a4a 100644 --- a/src/view/terminal/test_terminal.rs +++ b/src/view/terminal/test_terminal.rs @@ -100,7 +100,7 @@ impl Terminal for TestTerminal { } let mut data = self.data.lock().unwrap(); - let string_content = format!("{}", content); + let string_content = format!("{content}"); for (i, c) in string_content.chars().enumerate() { // Ignore characters beyond visible width.