From 16c897d8b473693a1c4e443cb9fe4f2aae53b6ed Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Thu, 31 Aug 2023 23:36:43 -0700 Subject: [PATCH] conflicts: leverage `Merge::map()` in `materialize_merge_result()` --- lib/src/conflicts.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/lib/src/conflicts.rs b/lib/src/conflicts.rs index ad74e4037..c1d5cc162 100644 --- a/lib/src/conflicts.rs +++ b/lib/src/conflicts.rs @@ -102,17 +102,8 @@ pub fn materialize_merge_result( single_hunk: &Merge, output: &mut dyn Write, ) -> std::io::Result<()> { - let removed_slices = single_hunk - .removes() - .iter() - .map(|hunk| hunk.0.as_slice()) - .collect_vec(); - let added_slices = single_hunk - .adds() - .iter() - .map(|hunk| hunk.0.as_slice()) - .collect_vec(); - let merge_result = files::merge(&removed_slices, &added_slices); + let slices = single_hunk.map(|content| content.0.as_slice()); + let merge_result = files::merge(slices.removes(), slices.adds()); match merge_result { MergeResult::Resolved(content) => { output.write_all(&content.0)?;