Implement Clippy suggestions
They were actually sensible for once???
This commit is contained in:
parent
2c2afb4b33
commit
4c2ad03a0e
16 changed files with 31 additions and 33 deletions
|
|
@ -35,12 +35,11 @@ pub struct DataManager {}
|
|||
|
||||
impl DataManager {
|
||||
pub async fn init() -> Result<(), DataManagerError> {
|
||||
let data_dir = match var_os("XDG_DATA_HOME") {
|
||||
Some(xdg_home_data_dir) => concat_os_str!(xdg_home_data_dir, "/zoodex"),
|
||||
None => {
|
||||
let data_dir = if let Some(xdg_home_data_dir) = var_os("XDG_DATA_HOME") {
|
||||
concat_os_str!(xdg_home_data_dir, "/zoodex")
|
||||
} else {
|
||||
let home_dir = var_os("HOME").ok_or(DataManagerError::NoHomeDir)?;
|
||||
concat_os_str!(home_dir, "/.local/share/zoodex")
|
||||
}
|
||||
};
|
||||
|
||||
let sqlite_manager = SqliteManager::new(data_dir.as_os_str()).await?;
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ async fn create_client(data_dir: &OsStr) -> Result<Client, DataManagerError> {
|
|||
Ok(())
|
||||
})
|
||||
.await
|
||||
.map(|_| client)
|
||||
.map(|()| client)
|
||||
})
|
||||
.await;
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ impl Component for App {
|
|||
fn init(_init: (), root: ApplicationWindow, sender: ComponentSender<App>) -> ComponentParts<App> {
|
||||
sender.oneshot_command(async {
|
||||
match DataManager::init().await {
|
||||
Ok(_) => AppCmdOutput::DataManagerReady,
|
||||
Ok(()) => AppCmdOutput::DataManagerReady,
|
||||
Err(error) => AppCmdOutput::DataManagerFailed(error),
|
||||
}
|
||||
});
|
||||
|
|
@ -64,7 +64,7 @@ impl Component for App {
|
|||
}
|
||||
AppCmdOutput::DataManagerFailed(error) => {
|
||||
// TODO: Show error in GUI.
|
||||
println!("Error occurred in data manager initialization: {:?}", error);
|
||||
println!("Error occurred in data manager initialization: {error:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ impl SimpleComponent for CollatableFilmGrid {
|
|||
|
||||
fn init(
|
||||
_init: (),
|
||||
_root: gtk4::Box,
|
||||
root: gtk4::Box,
|
||||
_sender: ComponentSender<CollatableFilmGrid>,
|
||||
) -> ComponentParts<CollatableFilmGrid> {
|
||||
let film_grid = FilmGrid::builder().launch(()).detach();
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ impl SimpleComponent for CollatableSeriesGrid {
|
|||
|
||||
fn init(
|
||||
_init: (),
|
||||
_root: gtk4::Box,
|
||||
root: gtk4::Box,
|
||||
_sender: ComponentSender<CollatableSeriesGrid>,
|
||||
) -> ComponentParts<CollatableSeriesGrid> {
|
||||
let series_grid = SeriesGrid::builder().launch(()).detach();
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ impl SimpleComponent for FilmCollationMenu {
|
|||
|
||||
fn init(
|
||||
_init: (),
|
||||
_root: gtk4::Box,
|
||||
root: gtk4::Box,
|
||||
sender: ComponentSender<FilmCollationMenu>,
|
||||
) -> ComponentParts<FilmCollationMenu> {
|
||||
let model = FilmCollationMenu {
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ impl SimpleComponent for SeriesCollationMenu {
|
|||
|
||||
fn init(
|
||||
_init: (),
|
||||
_root: gtk4::Box,
|
||||
root: gtk4::Box,
|
||||
sender: ComponentSender<SeriesCollationMenu>,
|
||||
) -> ComponentParts<SeriesCollationMenu> {
|
||||
let model = SeriesCollationMenu {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ impl SimpleComponent for FilmDetails {
|
|||
|
||||
fn init(
|
||||
film_overview: FilmOverview,
|
||||
_root: gtk4::Box,
|
||||
root: gtk4::Box,
|
||||
_sender: ComponentSender<FilmDetails>,
|
||||
) -> ComponentParts<FilmDetails> {
|
||||
let model = FilmDetails { film_overview };
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ impl SimpleComponent for SeriesDetails {
|
|||
|
||||
fn init(
|
||||
series_overview: SeriesOverview,
|
||||
_root: gtk4::Box,
|
||||
root: gtk4::Box,
|
||||
_sender: ComponentSender<SeriesDetails>,
|
||||
) -> ComponentParts<SeriesDetails> {
|
||||
let model = SeriesDetails { series_overview };
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ impl Component for FilmGrid {
|
|||
|
||||
fn init(
|
||||
_init: (),
|
||||
_root: ScrolledWindow,
|
||||
root: ScrolledWindow,
|
||||
sender: ComponentSender<FilmGrid>,
|
||||
) -> ComponentParts<FilmGrid> {
|
||||
let widgets = view_output!();
|
||||
|
|
@ -119,7 +119,7 @@ impl Component for FilmGrid {
|
|||
));
|
||||
}
|
||||
FilmGridCmdOutput::OverviewDataFailed(error) => {
|
||||
println!("Error occurred in loading films overview: {:?}", error);
|
||||
println!("Error occurred in loading films overview: {error:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ impl Component for SeriesGrid {
|
|||
|
||||
fn init(
|
||||
_init: (),
|
||||
_root: ScrolledWindow,
|
||||
root: ScrolledWindow,
|
||||
sender: ComponentSender<SeriesGrid>,
|
||||
) -> ComponentParts<SeriesGrid> {
|
||||
let widgets = view_output!();
|
||||
|
|
@ -119,7 +119,7 @@ impl Component for SeriesGrid {
|
|||
));
|
||||
}
|
||||
SeriesGridCmdOutput::OverviewDataFailed(error) => {
|
||||
println!("Error occurred in loading series overview: {:?}", error);
|
||||
println!("Error occurred in loading series overview: {error:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ impl FactoryComponent for FilmGridItem {
|
|||
#[name="original_name"]
|
||||
Label {
|
||||
set_visible: self.film.original_name.is_some(),
|
||||
set_cond_label: self.film.original_name.as_ref().map(String::as_str),
|
||||
set_cond_label: self.film.original_name.as_deref(),
|
||||
},
|
||||
|
||||
gtk4::Box {
|
||||
|
|
@ -121,7 +121,7 @@ impl FactoryComponent for FilmGridItem {
|
|||
root.toplevel_window().expect("root widget of FilmGridItem should be ancestor of a window")
|
||||
}),
|
||||
#[watch]
|
||||
set_child: self.details.as_ref().map(|details| details.widget()),
|
||||
set_child: self.details.as_ref().map(ComponentController::widget),
|
||||
connect_closed => FilmGridItemInput::DetailsClosed,
|
||||
},
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ impl FactoryComponent for FilmGridItem {
|
|||
// If no poster is present we don't need to do anything.
|
||||
FilmGridItemCmdOutput::NoPosterFound => {}
|
||||
FilmGridItemCmdOutput::PosterFailed(error) => {
|
||||
println!("Error occurred in loading film poster: {:?}", error);
|
||||
println!("Error occurred in loading film poster: {error:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ impl FactoryComponent for SeriesGridItem {
|
|||
#[name="original_name"]
|
||||
Label {
|
||||
set_visible: self.series.original_name.is_some(),
|
||||
set_cond_label: self.series.original_name.as_ref().map(String::as_str),
|
||||
set_cond_label: self.series.original_name.as_deref(),
|
||||
},
|
||||
|
||||
#[name="release_date"]
|
||||
|
|
@ -109,7 +109,7 @@ impl FactoryComponent for SeriesGridItem {
|
|||
root.toplevel_window().expect("root widget of FilmGridItem should be ancestor of a window")
|
||||
}),
|
||||
#[watch]
|
||||
set_child: self.details.as_ref().map(|details| details.widget()),
|
||||
set_child: self.details.as_ref().map(ComponentController::widget),
|
||||
connect_closed => SeriesGridItemInput::DetailsClosed,
|
||||
},
|
||||
}
|
||||
|
|
@ -166,7 +166,7 @@ impl FactoryComponent for SeriesGridItem {
|
|||
// If no poster is present we don't need to do anything.
|
||||
SeriesGridItemCmdOutput::NoPosterFound => {}
|
||||
SeriesGridItemCmdOutput::PosterFailed(error) => {
|
||||
println!("Error occurred in loading series poster: {:?}", error);
|
||||
println!("Error occurred in loading series poster: {error:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ impl SimpleComponent for MediaTypeSwitcher {
|
|||
|
||||
fn init(
|
||||
_init: (),
|
||||
_root: ToolbarView,
|
||||
root: ToolbarView,
|
||||
_sender: ComponentSender<MediaTypeSwitcher>,
|
||||
) -> ComponentParts<MediaTypeSwitcher> {
|
||||
let films_grid = CollatableFilmGrid::builder().launch(()).detach();
|
||||
|
|
|
|||
|
|
@ -12,10 +12,10 @@ where
|
|||
F: Fn(&I, &I) -> Ordering,
|
||||
I: FactoryComponent<Index = DynamicIndex>,
|
||||
{
|
||||
_sort_factory_vec(factory_vec, 0, factory_vec.len(), &compare);
|
||||
sort_factory_vec_inner(factory_vec, 0, factory_vec.len(), &compare);
|
||||
}
|
||||
|
||||
fn _sort_factory_vec<F, I>(
|
||||
fn sort_factory_vec_inner<F, I>(
|
||||
factory_vec: &mut FactoryVecDequeGuard<I>,
|
||||
start_index: usize,
|
||||
end_index: usize,
|
||||
|
|
@ -26,8 +26,8 @@ fn _sort_factory_vec<F, I>(
|
|||
{
|
||||
if end_index - start_index > 1 {
|
||||
let pivot = lomuto_partition(factory_vec, start_index, end_index, compare);
|
||||
_sort_factory_vec(factory_vec, start_index, pivot, compare);
|
||||
_sort_factory_vec(factory_vec, pivot + 1, end_index, compare);
|
||||
sort_factory_vec_inner(factory_vec, start_index, pivot, compare);
|
||||
sort_factory_vec_inner(factory_vec, pivot + 1, end_index, compare);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,9 +40,8 @@ pub trait CondDialogExt: IsA<Dialog> {
|
|||
// Unlike AdwDialogExt::present the parent is not a reference, so that using it
|
||||
// with Option::map is more ergonomic.
|
||||
fn cond_present<W: IsA<Widget>>(&self, parent: Option<W>) {
|
||||
match parent {
|
||||
Some(parent) => self.present(Some(&parent)),
|
||||
None => {}
|
||||
if let Some(parent) = parent {
|
||||
self.present(Some(&parent));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue