From ce53e9366ff81123cd605ad72aaa76af15f4f41c Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Thu, 9 Jan 2025 14:09:54 -0500 Subject: [PATCH] Refactor slightly to avoid a new clippy failure --- src/git_tool.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/git_tool.rs b/src/git_tool.rs index 344d8b7e..11d1e84a 100644 --- a/src/git_tool.rs +++ b/src/git_tool.rs @@ -136,7 +136,7 @@ pub struct Editor<'a> { run_editor: Box io::Result + 'a>, } -impl<'a> Editor<'a> { +impl Editor<'_> { /// Create a new editor for a temporary file. pub fn new(name: &str) -> io::Result { let tempfile = tempfile::Builder::new() @@ -174,12 +174,6 @@ impl<'a> Editor<'a> { ); } - #[cfg(test)] - /// Test-only method to mock out the actual invocation of the editor. - pub fn set_run_editor(&mut self, run_editor: impl FnOnce(&Path) -> io::Result + 'a) { - self.run_editor = Box::new(run_editor); - } - /// Add comment lines to the editor. Any newlines in the input will be /// normalized to the current platform, and a comment character will be /// added. @@ -260,6 +254,14 @@ impl<'a> Editor<'a> { } } +#[cfg(test)] +impl<'a> Editor<'a> { + /// Test-only method to mock out the actual invocation of the editor. + pub fn set_run_editor(&mut self, run_editor: impl FnOnce(&Path) -> io::Result + 'a) { + self.run_editor = Box::new(run_editor); + } +} + /// Read the git configuration to determine the value for GIT_EDITOR. fn git_pager() -> Option { let output = Command::new("git")