Fix a clippy lint
Some checks failed
Cargo CI / Build and Test (pull_request) Failing after 1m39s
Cargo CI / Lint (pull_request) Successful in 1m11s

This commit is contained in:
Wojciech Kozlowski 2024-02-18 02:26:09 +01:00
parent 7ceb610bde
commit 24daaff2a1
3 changed files with 15 additions and 20 deletions

View File

@ -21,13 +21,21 @@ pub type App<MH> = AppState<
>;
impl<MH: IMusicHoard> App<MH> {
pub fn new(music_hoard: MH) -> Self {
match AppMachine::new(music_hoard) {
Ok(browse) => browse.into(),
Err(critical) => critical.into(),
pub fn new(mut music_hoard: MH) -> Self {
let init_result = Self::init(&mut music_hoard);
let inner = AppInner::new(music_hoard);
match init_result {
Ok(()) => AppMachine::browse(inner).into(),
Err(err) => AppMachine::critical(inner, err.to_string()).into(),
}
}
fn init(music_hoard: &mut MH) -> Result<(), musichoard::Error> {
music_hoard.load_from_database()?;
music_hoard.rescan_library()?;
Ok(())
}
fn inner_ref(&self) -> &AppInner<MH> {
match self {
AppState::Browse(browse) => browse.inner_ref(),

View File

@ -2,7 +2,7 @@ use crate::tui::{
app::{
app::App,
selection::{Delta, ListSelection},
state::{critical::AppCritical, AppInner, AppMachine},
state::{AppInner, AppMachine},
AppPublic, AppState, IAppInteractBrowse,
},
lib::IMusicHoard,
@ -17,21 +17,6 @@ impl<MH: IMusicHoard> AppMachine<MH, AppBrowse> {
state: AppBrowse,
}
}
pub fn new(mut music_hoard: MH) -> Result<Self, AppMachine<MH, AppCritical>> {
let init_result = Self::init(&mut music_hoard);
let inner = AppInner::new(music_hoard);
match init_result {
Ok(()) => Ok(AppMachine::browse(inner)),
Err(err) => Err(AppMachine::critical(inner, err.to_string())),
}
}
fn init(music_hoard: &mut MH) -> Result<(), musichoard::Error> {
music_hoard.load_from_database()?;
music_hoard.rescan_library()?;
Ok(())
}
}
impl<MH: IMusicHoard> From<AppMachine<MH, AppBrowse>> for App<MH> {

View File

@ -59,6 +59,8 @@ impl<'a, MH: IMusicHoard> From<&'a mut AppInner<MH>> for AppPublicInner<'a> {
}
}
// FIXME: split tests - into parts that test functionality in isolation and move those where
// appropriate, and parts that verify transitions between states.
#[cfg(test)]
mod tests {
use musichoard::collection::Collection;