From 27ea8d2770b3c4e19ee4fe2e9943529ca6ffee5a Mon Sep 17 00:00:00 2001 From: Josh Megnauth Date: Mon, 3 Nov 2025 16:12:38 -0500 Subject: [PATCH] Clean up dependencies, lints `lazy_static` and `smol_str` weren't used. COSMIC Player used `dirs` once to find the user's home directory. Rust fixed and undeprecated its `home_dir` function in 1.85, which released earlier this year and is the MSRV of libcosmic. --- Cargo.lock | 3 --- Cargo.toml | 6 ------ src/main.rs | 15 ++++++--------- src/menu.rs | 6 +++--- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 383fa76..af1a1db 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1083,7 +1083,6 @@ name = "cosmic-player" version = "0.1.0" dependencies = [ "clap_lex", - "dirs", "env_logger", "fork", "gstreamer-tag", @@ -1093,13 +1092,11 @@ dependencies = [ "icu_collator", "icu_provider", "image", - "lazy_static", "libcosmic", "log", "mpris-server", "rust-embed", "serde", - "smol_str", "tempfile", "tokio", "url", diff --git a/Cargo.toml b/Cargo.toml index 14ed99f..c77b3a2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,10 +7,8 @@ edition = "2021" vergen = { version = "8", features = ["git", "gitcl"] } [dependencies] -dirs = "5" gstreamer-tag = "0.23" image = "0.24.9" -lazy_static = "1" serde = { version = "1", features = ["serde_derive"] } tempfile = "3" tokio = { version = "1", features = ["sync"] } @@ -45,10 +43,6 @@ features = ["tokio", "winit"] version = "0.8.1" optional = true -[dependencies.smol_str] -version = "0.2.1" -features = ["serde"] - [target.'cfg(unix)'.dependencies] fork = "0.2" diff --git a/src/main.rs b/src/main.rs index 53f6c1f..2f38a40 100644 --- a/src/main.rs +++ b/src/main.rs @@ -103,20 +103,19 @@ fn main() -> Result<(), Box> { localize::localize(); - let (config_handler, config) = match cosmic_config::Config::new(App::APP_ID, CONFIG_VERSION) { + let config = match cosmic_config::Config::new(App::APP_ID, CONFIG_VERSION) { Ok(config_handler) => { - let config = match Config::get_entry(&config_handler) { + match Config::get_entry(&config_handler) { Ok(ok) => ok, Err((errs, config)) => { log::error!("errors loading config: {:?}", errs); config } - }; - (Some(config_handler), config) + } } Err(err) => { log::error!("failed to create config handler: {}", err); - (None, Config::default()) + Config::default() } }; @@ -142,7 +141,6 @@ fn main() -> Result<(), Box> { settings = settings.size_limits(Limits::NONE.min_width(360.0).min_height(180.0)); let flags = Flags { - config_handler, config, config_state_handler, config_state, @@ -195,7 +193,6 @@ impl MenuAction for Action { #[derive(Clone)] pub struct Flags { - config_handler: Option, config: Config, config_state_handler: Option, config_state: ConfigState, @@ -1420,7 +1417,7 @@ impl Application for App { Command::none() } - fn header_start(&self) -> Vec> { + fn header_start(&self) -> Vec> { vec![menu::menu_bar( &self.flags.config, &self.flags.config_state, @@ -1430,7 +1427,7 @@ impl Application for App { } /// Creates a view after each update. - fn view(&self) -> Element { + fn view(&self) -> Element<'_, Self::Message> { let theme = theme::active(); let cosmic_theme::Spacing { space_xxs, diff --git a/src/menu.rs b/src/menu.rs index e277db1..fe8b102 100644 --- a/src/menu.rs +++ b/src/menu.rs @@ -10,12 +10,12 @@ use std::{collections::HashMap, path::PathBuf}; use crate::{fl, Action, Config, ConfigState, Message}; pub fn menu_bar<'a>( - config: &Config, + _config: &Config, config_state: &ConfigState, key_binds: &HashMap, - projects: &Vec<(String, PathBuf)>, + projects: &[(String, PathBuf)], ) -> Element<'a, Message> { - let home_dir_opt = dirs::home_dir(); + let home_dir_opt = std::env::home_dir(); let format_path = |path: &PathBuf| -> String { if let Some(home_dir) = &home_dir_opt { if let Ok(part) = path.strip_prefix(home_dir) {