Fix a clippy lint
This commit is contained in:
parent
7ceb610bde
commit
24daaff2a1
@ -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(),
|
||||
|
@ -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> {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user