Skip to content

Commit

Permalink
Refactor slightly to avoid a new clippy failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mystor committed Jan 9, 2025
1 parent 866f148 commit ce53e93
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/git_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ pub struct Editor<'a> {
run_editor: Box<dyn FnOnce(&Path) -> io::Result<bool> + 'a>,
}

impl<'a> Editor<'a> {
impl Editor<'_> {
/// Create a new editor for a temporary file.
pub fn new(name: &str) -> io::Result<Self> {
let tempfile = tempfile::Builder::new()
Expand Down Expand Up @@ -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<bool> + '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.
Expand Down Expand Up @@ -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<bool> + 'a) {
self.run_editor = Box::new(run_editor);
}
}

/// Read the git configuration to determine the value for GIT_EDITOR.
fn git_pager() -> Option<String> {
let output = Command::new("git")
Expand Down

0 comments on commit ce53e93

Please sign in to comment.