Streamline adding new URL types #122
@ -117,11 +117,8 @@ impl Artist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn remove_from_property<S: AsRef<str>>(&mut self, property: S, values: Vec<S>) {
|
pub fn remove_from_property<S: AsRef<str>>(&mut self, property: S, values: Vec<S>) {
|
||||||
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.retain(|val| !values.iter().any(|x| x.as_ref() == val));
|
||||||
wojtek marked this conversation as resolved
|
|||||||
container
|
|
||||||
});
|
|
||||||
if let Some(container) = container {
|
|
||||||
if container.is_empty() {
|
if container.is_empty() {
|
||||||
self.properties.remove(property.as_ref());
|
self.properties.remove(property.as_ref());
|
||||||
}
|
}
|
||||||
@ -129,17 +126,10 @@ impl Artist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_property<S: AsRef<str> + Into<String>>(&mut self, property: S, values: Vec<S>) {
|
pub fn set_property<S: AsRef<str> + Into<String>>(&mut self, property: S, values: Vec<S>) {
|
||||||
let mut values = values.into_iter().map(|s| s.into()).collect();
|
self.properties.insert(
|
||||||
|
property.into(),
|
||||||
match self.properties.get_mut(property.as_ref()) {
|
values.into_iter().map(|s| s.into()).collect(),
|
||||||
Some(container) => {
|
);
|
||||||
container.clear();
|
|
||||||
container.append(&mut values);
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
self.properties.insert(property.into(), values);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear_property<S: AsRef<str>>(&mut self, property: S) {
|
pub fn clear_property<S: AsRef<str>>(&mut self, property: S) {
|
||||||
|
Loading…
Reference in New Issue
Block a user
Split map from the get_mut. Will be more legible and the container variable is used later anyway.