From 14ab109197442a1c00513a6b195afdbfa6f0bfbd Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Thu, 2 Jan 2025 15:24:45 +0100 Subject: [PATCH] Prefer into_iter over drain --- src/core/collection/artist.rs | 8 ++++---- src/core/collection/merge.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/collection/artist.rs b/src/core/collection/artist.rs index 1ab01b1..40b395c 100644 --- a/src/core/collection/artist.rs +++ b/src/core/collection/artist.rs @@ -72,10 +72,10 @@ impl Artist { fn merge_albums_by_lib_id( primary_albums: &mut [Album], - mut secondary_albums: Vec, + secondary_albums: Vec, ) -> HashMap> { let mut secondary_without_id = HashMap::>::new(); - for secondary_album in secondary_albums.drain(..) { + for secondary_album in secondary_albums.into_iter() { let unmerged = Artist::merge_album_by_lib_id(primary_albums, secondary_album); if let Some(secondary_album) = unmerged { secondary_without_id @@ -89,9 +89,9 @@ impl Artist { fn merge_albums_by_title( primary_albums: &mut Vec, - mut secondary_without_id: HashMap>, + secondary_without_id: HashMap>, ) { - for (title, mut secondary_albums) in secondary_without_id.drain() { + for (title, mut secondary_albums) in secondary_without_id.into_iter() { let mut iter = primary_albums.iter_mut(); match iter.find(|album| album.meta.id.title == title) { Some(ref mut primary_album) => { diff --git a/src/core/collection/merge.rs b/src/core/collection/merge.rs index ebfed09..42d833a 100644 --- a/src/core/collection/merge.rs +++ b/src/core/collection/merge.rs @@ -23,8 +23,8 @@ impl Merge for Vec { } impl Merge for HashMap> { - fn merge_in_place(&mut self, mut other: Self) { - for (other_key, other_value) in other.drain() { + fn merge_in_place(&mut self, other: Self) { + for (other_key, other_value) in other.into_iter() { if let Some(ref mut value) = self.get_mut(&other_key) { value.merge_in_place(other_value) } else {