From b2cbe0732d9216280f3566702c0af9b9a8040ddf Mon Sep 17 00:00:00 2001 From: Pi-Cla Date: Sun, 31 Mar 2024 13:22:46 -0600 Subject: Apply cargo clippy lints --- src/commute.rs | 6 ++---- src/lib.rs | 15 ++++++--------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/commute.rs b/src/commute.rs index 6009130..892a755 100644 --- a/src/commute.rs +++ b/src/commute.rs @@ -77,10 +77,8 @@ where // to be reverse line order (bottom to top), which also // happens to be reverse of the order they're stored .rev() - .fold(Some(after.clone()), |after, next| { - after - .and_then(|after| commute(next, &after)) - .map(|(commuted_after, _)| commuted_after) + .try_fold(after.clone(), |after, next| { + commute(next, &after).map(|(commuted_after, _)| commuted_after) }) } diff --git a/src/lib.rs b/src/lib.rs index 6450a1a..8929c85 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -39,7 +39,7 @@ pub fn run(config: &mut Config) -> Result<()> { } fn run_with_repo(config: &Config, repo: &git2::Repository) -> Result<()> { - let stack = stack::working_stack(&repo, config.base, config.force, config.logger)?; + let stack = stack::working_stack(repo, config.base, config.force, config.logger)?; if stack.is_empty() { crit!(config.logger, "No commits available to fix up, exiting"); return Ok(()); @@ -91,10 +91,7 @@ fn run_with_repo(config: &Config, repo: &git2::Repository) -> Result<()> { } let summary_counts = stack::summary_counts(&stack); - ( - stack.into_iter().zip(diffs.into_iter()).collect(), - summary_counts, - ) + (stack.into_iter().zip(diffs).collect(), summary_counts) }; let mut head_tree = repo.head()?.peel_to_tree()?; @@ -188,7 +185,7 @@ fn run_with_repo(config: &Config, repo: &git2::Repository) -> Result<()> { let mut commuted_old_path = old_path; let mut commuted_index_hunk = isolated_hunk; - 'commit: for &(ref commit, ref diff) in &stack { + 'commit: for (commit, diff) in &stack { let c_logger = config.logger.new(o!( "commit" => commit.id().to_string(), )); @@ -271,7 +268,7 @@ fn run_with_repo(config: &Config, repo: &git2::Repository) -> Result<()> { } } - let target_always_sha: bool = config::fixup_target_always_sha(&repo); + let target_always_sha: bool = config::fixup_target_always_sha(repo); hunks_with_commit.sort_by_key(|h| h.dest_commit.id()); // * apply all hunks that are going to be fixed up into `dest_commit` @@ -286,7 +283,7 @@ fn run_with_repo(config: &Config, repo: &git2::Repository) -> Result<()> { .zip(hunks_with_commit.iter().skip(1).map(Some).chain([None])) { let new_head_tree = apply_hunk_to_tree( - &repo, + repo, &head_tree, ¤t.hunk_to_apply, ¤t.index_patch.old_path, @@ -373,7 +370,7 @@ fn run_with_repo(config: &Config, repo: &git2::Repository) -> Result<()> { assert!(number_of_parents <= 1); let mut command = Command::new("git"); - command.args(&["rebase", "--interactive", "--autosquash", "--autostash"]); + command.args(["rebase", "--interactive", "--autosquash", "--autostash"]); if number_of_parents == 0 { command.arg("--root"); -- cgit v1.2.3