diff --git a/src/core/collection/artist.rs b/src/core/collection/artist.rs index 15ab2d6..ee58257 100644 --- a/src/core/collection/artist.rs +++ b/src/core/collection/artist.rs @@ -117,11 +117,8 @@ impl Artist { } pub fn remove_from_property>(&mut self, property: S, values: Vec) { - let container = self.properties.get_mut(property.as_ref()).map(|container| { + if let Some(container) = self.properties.get_mut(property.as_ref()) { container.retain(|val| !values.iter().any(|x| x.as_ref() == val)); - container - }); - if let Some(container) = container { if container.is_empty() { self.properties.remove(property.as_ref()); } @@ -129,17 +126,10 @@ impl Artist { } pub fn set_property + Into>(&mut self, property: S, values: Vec) { - let mut values = values.into_iter().map(|s| s.into()).collect(); - - match self.properties.get_mut(property.as_ref()) { - Some(container) => { - container.clear(); - container.append(&mut values); - } - None => { - self.properties.insert(property.into(), values); - } - } + self.properties.insert( + property.into(), + values.into_iter().map(|s| s.into()).collect(), + ); } pub fn clear_property>(&mut self, property: S) {