Lints
This commit is contained in:
parent
e136103ead
commit
19f201e1ac
@ -89,7 +89,7 @@ impl<Database, Library> IMusicHoardBasePrivate for MusicHoard<Database, Library>
|
||||
|
||||
fn filter_collection(&self) -> Collection {
|
||||
let iter = self.collection.iter();
|
||||
iter.map(|a| self.filter_artist(a)).flatten().collect()
|
||||
iter.flat_map(|a| self.filter_artist(a)).collect()
|
||||
}
|
||||
|
||||
fn filter_artist(&self, artist: &Artist) -> Option<Artist> {
|
||||
@ -149,10 +149,7 @@ impl<Database, Library> IMusicHoardBasePrivate for MusicHoard<Database, Library>
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
collection::{
|
||||
album::{AlbumMeta, AlbumPrimaryType},
|
||||
artist::ArtistMeta,
|
||||
},
|
||||
collection::{album::AlbumPrimaryType, artist::ArtistMeta},
|
||||
core::testmod::FULL_COLLECTION,
|
||||
filter::AlbumField,
|
||||
};
|
||||
@ -331,14 +328,16 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn filtered() {
|
||||
let mut mh = MusicHoard::default();
|
||||
mh.collection = vec![Artist {
|
||||
let mut mh = MusicHoard {
|
||||
collection: vec![Artist {
|
||||
meta: ArtistMeta::new(ArtistId::new("Artist")),
|
||||
albums: vec![
|
||||
Album::new(AlbumId::new("Album 1")),
|
||||
Album::new(AlbumId::new("Album 2")),
|
||||
],
|
||||
}];
|
||||
}],
|
||||
..Default::default()
|
||||
};
|
||||
mh.collection[0].albums[0].meta.info.primary_type = Some(AlbumPrimaryType::Ep);
|
||||
mh.collection[0].albums[0].meta.info.primary_type = Some(AlbumPrimaryType::Album);
|
||||
|
||||
|
@ -1,6 +1,8 @@
|
||||
use crate::core::{
|
||||
interface::{database::IDatabase, library::ILibrary},
|
||||
musichoard::{database::IMusicHoardDatabase, Error, MusicHoard, NoDatabase, NoLibrary, CollectionFilter},
|
||||
musichoard::{
|
||||
database::IMusicHoardDatabase, CollectionFilter, Error, MusicHoard, NoDatabase, NoLibrary,
|
||||
},
|
||||
};
|
||||
|
||||
/// Builder for [`MusicHoard`]. Its purpose is to make it easier to set various combinations of
|
||||
|
@ -21,7 +21,7 @@ impl CollectionFilter {
|
||||
include && !except
|
||||
}
|
||||
|
||||
fn filter_and(empty: bool, group: &Vec<Vec<AlbumField>>, album: &Album) -> bool {
|
||||
fn filter_and(empty: bool, group: &[Vec<AlbumField>], album: &Album) -> bool {
|
||||
let mut filter = !group.is_empty() || empty;
|
||||
for field in group.iter() {
|
||||
filter = filter && Self::filter_or(field, album);
|
||||
@ -29,7 +29,7 @@ impl CollectionFilter {
|
||||
filter
|
||||
}
|
||||
|
||||
fn filter_or(group: &Vec<AlbumField>, album: &Album) -> bool {
|
||||
fn filter_or(group: &[AlbumField], album: &Album) -> bool {
|
||||
let mut filter = false;
|
||||
for field in group.iter() {
|
||||
filter = filter || Self::filter_field(field, album);
|
||||
@ -42,7 +42,7 @@ impl CollectionFilter {
|
||||
AlbumField::PrimaryType(filter) => *filter == album.meta.info.primary_type,
|
||||
AlbumField::SecondaryType(filter) => {
|
||||
let types = &album.meta.info.secondary_types;
|
||||
types.iter().find(|st| *st == filter).is_some()
|
||||
types.iter().any(|st| st == filter)
|
||||
}
|
||||
AlbumField::Ownership(filter) => *filter == album.get_ownership(),
|
||||
}
|
||||
|
@ -28,19 +28,15 @@ impl IAppInteractReload for AppMachine<ReloadState> {
|
||||
type APP = App;
|
||||
|
||||
fn reload_library(mut self) -> Self::APP {
|
||||
let previous = KeySelection::get(
|
||||
self.inner.music_hoard.get_filtered(),
|
||||
&self.inner.selection,
|
||||
);
|
||||
let previous =
|
||||
KeySelection::get(self.inner.music_hoard.get_filtered(), &self.inner.selection);
|
||||
let result = self.inner.music_hoard.rescan_library();
|
||||
self.refresh(previous, result)
|
||||
}
|
||||
|
||||
fn reload_database(mut self) -> Self::APP {
|
||||
let previous = KeySelection::get(
|
||||
self.inner.music_hoard.get_filtered(),
|
||||
&self.inner.selection,
|
||||
);
|
||||
let previous =
|
||||
KeySelection::get(self.inner.music_hoard.get_filtered(), &self.inner.selection);
|
||||
let result = self.inner.music_hoard.reload_database();
|
||||
self.refresh(previous, result)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user