Streamline adding new URL types #122
@ -1,5 +1,5 @@
|
||||
use std::{
|
||||
collections::{HashMap, BTreeMap},
|
||||
collections::{BTreeMap, HashMap},
|
||||
fmt::{self, Debug, Display},
|
||||
mem,
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
use std::{cmp::Ordering, iter::Peekable, collections::HashMap, hash::Hash};
|
||||
use std::{cmp::Ordering, collections::HashMap, hash::Hash, iter::Peekable};
|
||||
|
||||
/// A trait for merging two objects. The merge is asymmetric with the left argument considered to be
|
||||
/// the primary whose properties are to be kept in case of collisions.
|
||||
|
@ -124,9 +124,9 @@ impl<LIB, DB> MusicHoard<LIB, DB> {
|
||||
&mut self,
|
||||
artist_id: ID,
|
||||
) -> Result<(), Error> {
|
||||
Ok(self
|
||||
.get_artist_mut_or_err(artist_id.as_ref())?
|
||||
.clear_musicbrainz_url())
|
||||
self.get_artist_mut_or_err(artist_id.as_ref())?
|
||||
.clear_musicbrainz_url();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn add_to_property<ID: AsRef<ArtistId>, S: AsRef<str> + Into<String>>(
|
||||
@ -135,9 +135,9 @@ impl<LIB, DB> MusicHoard<LIB, DB> {
|
||||
property: S,
|
||||
values: Vec<S>,
|
||||
) -> Result<(), Error> {
|
||||
Ok(self
|
||||
.get_artist_mut_or_err(artist_id.as_ref())?
|
||||
.add_to_property(property, values))
|
||||
self.get_artist_mut_or_err(artist_id.as_ref())?
|
||||
.add_to_property(property, values);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn remove_from_property<ID: AsRef<ArtistId>, S: AsRef<str>>(
|
||||
@ -146,9 +146,9 @@ impl<LIB, DB> MusicHoard<LIB, DB> {
|
||||
property: S,
|
||||
values: Vec<S>,
|
||||
) -> Result<(), Error> {
|
||||
Ok(self
|
||||
.get_artist_mut_or_err(artist_id.as_ref())?
|
||||
.remove_from_property(property, values))
|
||||
self.get_artist_mut_or_err(artist_id.as_ref())?
|
||||
.remove_from_property(property, values);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn set_property<ID: AsRef<ArtistId>, S: AsRef<str> + Into<String>>(
|
||||
@ -157,9 +157,9 @@ impl<LIB, DB> MusicHoard<LIB, DB> {
|
||||
property: S,
|
||||
values: Vec<S>,
|
||||
) -> Result<(), Error> {
|
||||
Ok(self
|
||||
.get_artist_mut_or_err(artist_id.as_ref())?
|
||||
.set_property(property, values))
|
||||
self.get_artist_mut_or_err(artist_id.as_ref())?
|
||||
.set_property(property, values);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn clear_property<ID: AsRef<ArtistId>, S: AsRef<str>>(
|
||||
@ -167,9 +167,9 @@ impl<LIB, DB> MusicHoard<LIB, DB> {
|
||||
artist_id: ID,
|
||||
property: S,
|
||||
) -> Result<(), Error> {
|
||||
Ok(self
|
||||
.get_artist_mut_or_err(artist_id.as_ref())?
|
||||
.clear_property(property))
|
||||
self.get_artist_mut_or_err(artist_id.as_ref())?
|
||||
.clear_property(property);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn sort(collection: &mut [Artist]) {
|
||||
|
@ -1,10 +1,10 @@
|
||||
use std::collections::HashMap;
|
||||
use musichoard::collection::{
|
||||
album::{Album, AlbumId},
|
||||
artist::{Artist, ArtistId, MusicBrainz},
|
||||
track::{Format, Quality, Track, TrackId},
|
||||
};
|
||||
use once_cell::sync::Lazy;
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::tests::*;
|
||||
|
||||
|
@ -206,7 +206,7 @@ impl<'a> ArtistOverlay<'a> {
|
||||
list_indent: &str,
|
||||
) -> String {
|
||||
let mut vec: Vec<(&str, &Vec<T>)> = map.iter().map(|(k, v)| (k.as_ref(), v)).collect();
|
||||
vec.sort_by(|x, y| x.0.cmp(&y.0));
|
||||
vec.sort_by(|x, y| x.0.cmp(y.0));
|
||||
|
||||
let indent = format!("\n{item_indent}");
|
||||
let list = vec
|
||||
|
Loading…
Reference in New Issue
Block a user