From 1bacf345f03bdfbfd9057a9c2c53eb165a15d200 Mon Sep 17 00:00:00 2001 From: funman300 Date: Fri, 17 Apr 2026 21:35:27 -0700 Subject: [PATCH] Apply rustfmt pass across all modules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pure whitespace normalization — no logic changes. Mostly: - collapsing multi-line match/if arms rustfmt prefers inline - inlining short `with_context`/`ok_or_else` closures - reformatting nested method chains for consistency Build and clippy stay clean. Co-Authored-By: Claude Opus 4.7 --- src/config.rs | 54 ++++++++++++++----------------------------------- src/detect.rs | 16 +++------------ src/diagnose.rs | 31 +++++++++++++++------------- src/main.rs | 51 ++++++++++++++++++++++------------------------ src/proton.rs | 29 ++++++++++++++++---------- src/service.rs | 9 +++------ src/setup.rs | 12 +++-------- 7 files changed, 83 insertions(+), 119 deletions(-) diff --git a/src/config.rs b/src/config.rs index 6d59107..b6dc34e 100644 --- a/src/config.rs +++ b/src/config.rs @@ -104,8 +104,7 @@ fn regex_escape(s: &str) -> String { for c in s.chars() { if matches!( c, - '.' | '*' | '?' | '+' | '(' | ')' | '[' | ']' - | '{' | '}' | '|' | '\\' | '^' | '$' + '.' | '*' | '?' | '+' | '(' | ')' | '[' | ']' | '{' | '}' | '|' | '\\' | '^' | '$' ) { out.push('\\'); } @@ -237,9 +236,8 @@ impl Config { } Err(e) => { let bak = path.with_extension("toml.bak"); - std::fs::rename(&path, &bak).with_context(|| { - format!("Failed to back up stale config to {bak:?}") - })?; + std::fs::rename(&path, &bak) + .with_context(|| format!("Failed to back up stale config to {bak:?}"))?; eprintln!("warning: couldn't parse {}: {e}", path.display()); eprintln!( " backed up to {} — writing fresh config with presets", @@ -305,8 +303,7 @@ impl Config { anyhow::bail!("launcher '{name}' already exists"); } let display = display.unwrap_or_else(|| name.clone()); - let prefix_dir = prefix_dir - .unwrap_or_else(|| home_dir().join("Games").join(&name)); + let prefix_dir = prefix_dir.unwrap_or_else(|| home_dir().join("Games").join(&name)); let gameid = gameid.unwrap_or_else(|| format!("umu-{name}")); let process_pattern = process_pattern.unwrap_or_else(|| { exe_path @@ -346,13 +343,9 @@ impl Config { .launchers .iter_mut() .find(|l| l.name == launcher) - .ok_or_else(|| { - anyhow::anyhow!("no launcher named '{launcher}'") - })?; + .ok_or_else(|| anyhow::anyhow!("no launcher named '{launcher}'"))?; if l.games.iter().any(|g| g.name == name) { - anyhow::bail!( - "launcher '{launcher}' already has a game named '{name}'" - ); + anyhow::bail!("launcher '{launcher}' already has a game named '{name}'"); } let display = display.unwrap_or_else(|| name.clone()); l.games.push(Game { @@ -365,9 +358,7 @@ impl Config { gamescope, }); self.save()?; - println!( - "\x1b[1;32m✓\x1b[0m Added game '{name}' under launcher '{launcher}'." - ); + println!("\x1b[1;32m✓\x1b[0m Added game '{name}' under launcher '{launcher}'."); Ok(()) } @@ -376,15 +367,11 @@ impl Config { .launchers .iter_mut() .find(|l| l.name == launcher) - .ok_or_else(|| { - anyhow::anyhow!("no launcher named '{launcher}'") - })?; + .ok_or_else(|| anyhow::anyhow!("no launcher named '{launcher}'"))?; let before = l.games.len(); l.games.retain(|g| g.name != name); if l.games.len() == before { - anyhow::bail!( - "launcher '{launcher}' has no game named '{name}'" - ); + anyhow::bail!("launcher '{launcher}' has no game named '{name}'"); } self.save()?; println!("\x1b[1;32m✓\x1b[0m Removed game '{name}' from '{launcher}'."); @@ -410,17 +397,10 @@ impl Config { .launchers .iter_mut() .find(|l| l.name == launcher) - .ok_or_else(|| { - anyhow::anyhow!("no launcher named '{launcher}'") - })?; - let g = l - .games - .iter_mut() - .find(|g| g.name == name) - .ok_or_else(|| { - anyhow::anyhow!( - "launcher '{launcher}' has no game named '{name}'" - ) + .ok_or_else(|| anyhow::anyhow!("no launcher named '{launcher}'"))?; + let g = + l.games.iter_mut().find(|g| g.name == name).ok_or_else(|| { + anyhow::anyhow!("launcher '{launcher}' has no game named '{name}'") })?; if let Some(v) = gamemode { g.gamemode = v; @@ -432,9 +412,7 @@ impl Config { g.gamescope = v; } self.save()?; - println!( - "\x1b[1;32m✓\x1b[0m Updated flags for '{launcher}/{name}'." - ); + println!("\x1b[1;32m✓\x1b[0m Updated flags for '{launcher}/{name}'."); Ok(()) } @@ -460,9 +438,7 @@ impl Config { compat_dir: Option, ) -> Result<()> { if proton_version.is_none() && compat_dir.is_none() { - anyhow::bail!( - "nothing to set — pass --proton-version or --compat-dir" - ); + anyhow::bail!("nothing to set — pass --proton-version or --compat-dir"); } if let Some(v) = proton_version { self.proton_version = v; diff --git a/src/detect.rs b/src/detect.rs index 98c607f..5ab9b7d 100644 --- a/src/detect.rs +++ b/src/detect.rs @@ -80,10 +80,7 @@ fn collect_prefixes(dir: &Path, depth: u32, out: &mut Vec) { } } -fn match_launchers( - config: &Config, - prefixes: &[PathBuf], -) -> HashMap> { +fn match_launchers(config: &Config, prefixes: &[PathBuf]) -> HashMap> { let mut by_launcher: HashMap> = HashMap::new(); for l in &config.launchers { for prefix in prefixes { @@ -114,11 +111,7 @@ fn print_findings(config: &Config, by_launcher: &HashMap>) Some(matches) => { let detected = &matches[0]; if *detected == l.prefix_dir { - println!( - " \x1b[1;32m✓\x1b[0m {:12} {}", - l.name, - detected.display() - ); + println!(" \x1b[1;32m✓\x1b[0m {:12} {}", l.name, detected.display()); } else { any_divergent = true; println!( @@ -136,10 +129,7 @@ fn print_findings(config: &Config, by_launcher: &HashMap>) } } -fn apply_findings( - config: &Config, - by_launcher: &HashMap>, -) -> Result<()> { +fn apply_findings(config: &Config, by_launcher: &HashMap>) -> Result<()> { let mut c = config.clone(); let mut updated = 0; let mut ambiguous = 0; diff --git a/src/diagnose.rs b/src/diagnose.rs index 06b47bd..15b4662 100644 --- a/src/diagnose.rs +++ b/src/diagnose.rs @@ -12,10 +12,18 @@ struct Check { impl Check { fn pass(label: impl Into, detail: impl Into) -> Self { - Self { label: label.into(), pass: true, detail: detail.into() } + Self { + label: label.into(), + pass: true, + detail: detail.into(), + } } fn fail(label: impl Into, detail: impl Into) -> Self { - Self { label: label.into(), pass: false, detail: detail.into() } + Self { + label: label.into(), + pass: false, + detail: detail.into(), + } } } @@ -81,7 +89,10 @@ fn global_vulkan_check() -> Check { if ok { Check::pass("vulkan", "vulkaninfo OK") } else { - Check::fail("vulkan", "vulkaninfo failed — check GPU drivers / vulkan-tools") + Check::fail( + "vulkan", + "vulkaninfo failed — check GPU drivers / vulkan-tools", + ) } } @@ -130,10 +141,7 @@ fn wineserver_check(config: &Config) -> Check { if count == 0 { return Check::pass("wine procs", "no wineserver running"); } - let any_running = config - .launchers - .iter() - .any(crate::launcher::is_running); + let any_running = config.launchers.iter().any(crate::launcher::is_running); if any_running { Check::pass( "wine procs", @@ -142,9 +150,7 @@ fn wineserver_check(config: &Config) -> Check { } else { Check::fail( "wine procs", - format!( - "{count} stale wineserver process(es) — try: umutray kill" - ), + format!("{count} stale wineserver process(es) — try: umutray kill"), ) } } @@ -190,10 +196,7 @@ fn launcher_checks(l: &Launcher) -> Vec { } if is_owned_by_current_user(&l.prefix_dir) { - out.push(Check::pass( - format!("{tag} owner"), - "owned by current user", - )); + out.push(Check::pass(format!("{tag} owner"), "owned by current user")); } else { out.push(Check::fail( format!("{tag} owner"), diff --git a/src/main.rs b/src/main.rs index b6db57d..c85902a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -188,10 +188,7 @@ enum ConfigAction { gamescope: Option, }, /// Remove a game from a launcher - RemoveGame { - launcher: String, - name: String, - }, + RemoveGame { launcher: String, name: String }, /// Toggle per-game overlay flags SetGameFlags { launcher: String, @@ -267,7 +264,10 @@ fn main() -> Result<()> { } } - Commands::Play { launcher: lname, game: gname } => { + Commands::Play { + launcher: lname, + game: gname, + } => { let l = config.find(&lname).ok_or_else(|| { anyhow::anyhow!("unknown launcher '{lname}' — try `umutray launchers`") })?; @@ -294,7 +294,11 @@ fn main() -> Result<()> { println!(" {}:", l.display); for g in &l.games { let installed = g.full_exe_path(l).exists(); - let marker = if installed { "\x1b[1;32m✓\x1b[0m" } else { "·" }; + let marker = if installed { + "\x1b[1;32m✓\x1b[0m" + } else { + "·" + }; let flags = format_game_flags(g); println!(" {marker} {:14} {}{}", g.name, g.display, flags); } @@ -312,7 +316,11 @@ fn main() -> Result<()> { detect::run(&config, &dir, apply)?; } - Commands::UpdateProton { latest, version, list } => { + Commands::UpdateProton { + latest, + version, + list, + } => { proton::run(&config, latest, version, list)?; } @@ -322,7 +330,10 @@ fn main() -> Result<()> { println!("{}", config::Config::config_path()?.display()); } ConfigAction::Edit => config::Config::edit()?, - ConfigAction::Set { proton_version, compat_dir } => { + ConfigAction::Set { + proton_version, + compat_dir, + } => { let mut c = config; c.set_globals(proton_version, compat_dir)?; } @@ -360,18 +371,9 @@ fn main() -> Result<()> { gamescope, } => { let mut c = config; - let gs = gamescope.map(|s| { - s.split_whitespace().map(String::from).collect::>() - }); - c.add_game( - &launcher, - name, - display, - exe_path, - gamemode, - mangohud, - gs, - )?; + let gs = + gamescope.map(|s| s.split_whitespace().map(String::from).collect::>()); + c.add_game(&launcher, name, display, exe_path, gamemode, mangohud, gs)?; } ConfigAction::RemoveGame { launcher, name } => { let mut c = config; @@ -388,13 +390,8 @@ fn main() -> Result<()> { let gs_update = if no_gamescope { Some(None) } else { - gamescope.map(|s| { - Some( - s.split_whitespace() - .map(String::from) - .collect::>(), - ) - }) + gamescope + .map(|s| Some(s.split_whitespace().map(String::from).collect::>())) }; let mut c = config; c.set_game_flags(&launcher, &name, gamemode, mangohud, gs_update)?; diff --git a/src/proton.rs b/src/proton.rs index 1d429e8..f5223aa 100644 --- a/src/proton.rs +++ b/src/proton.rs @@ -3,8 +3,7 @@ use anyhow::{Context, Result}; use serde::Deserialize; use std::io::Write; -const GITHUB_API: &str = - "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases"; +const GITHUB_API: &str = "https://api.github.com/repos/GloriousEggroll/proton-ge-custom/releases"; #[derive(Deserialize)] struct Release { @@ -153,7 +152,11 @@ fn print_list(config: &Config) -> Result<()> { let releases = fetch_releases(10)?; for r in &releases { let installed = config.proton_compat_dir.join(&r.tag_name).exists(); - let marker = if installed { " \x1b[1;32m✓ installed\x1b[0m" } else { "" }; + let marker = if installed { + " \x1b[1;32m✓ installed\x1b[0m" + } else { + "" + }; println!(" {}{}", r.tag_name, marker); } Ok(()) @@ -170,7 +173,12 @@ struct ProgressWriter { impl ProgressWriter { fn new(inner: W, total: Option) -> Self { - Self { inner, total, written: 0, last_print: 0 } + Self { + inner, + total, + written: 0, + last_print: 0, + } } fn finish(&mut self) { @@ -189,12 +197,7 @@ impl Write for ProgressWriter { match self.total { Some(t) => { let pct = (self.written as f64 / t as f64) * 100.0; - eprint!( - "\r {:.1}% ({} / {} MiB)", - pct, - self.written >> 20, - t >> 20, - ); + eprint!("\r {:.1}% ({} / {} MiB)", pct, self.written >> 20, t >> 20,); } None => eprint!("\r {} MiB", self.written >> 20), } @@ -217,7 +220,11 @@ fn pick_interactively(config: &Config) -> Result { println!("Recent GE-Proton releases:"); for (i, r) in releases.iter().enumerate() { let installed = config.proton_compat_dir.join(&r.tag_name).exists(); - let marker = if installed { " \x1b[1;32m✓\x1b[0m" } else { "" }; + let marker = if installed { + " \x1b[1;32m✓\x1b[0m" + } else { + "" + }; println!(" {:2}) {}{}", i + 1, r.tag_name, marker); } diff --git a/src/service.rs b/src/service.rs index 826f23f..1c94712 100644 --- a/src/service.rs +++ b/src/service.rs @@ -43,13 +43,11 @@ fn systemctl(args: &[&str]) -> Result<()> { /// Write the unit, reload systemd, and enable+start the service. pub fn install() -> Result<()> { - let exe = std::env::current_exe() - .context("Cannot determine path to own executable")?; + let exe = std::env::current_exe().context("Cannot determine path to own executable")?; let path = unit_path()?; if let Some(parent) = path.parent() { - std::fs::create_dir_all(parent) - .with_context(|| format!("Failed to create {parent:?}"))?; + std::fs::create_dir_all(parent).with_context(|| format!("Failed to create {parent:?}"))?; } let contents = render_unit(&exe); @@ -77,8 +75,7 @@ pub fn uninstall() -> Result<()> { let _ = systemctl(&["disable", "--now", UNIT_NAME]); if path.exists() { - std::fs::remove_file(&path) - .with_context(|| format!("Failed to remove {path:?}"))?; + std::fs::remove_file(&path).with_context(|| format!("Failed to remove {path:?}"))?; println!("Removed {}", path.display()); } else { println!("No unit file at {}", path.display()); diff --git a/src/setup.rs b/src/setup.rs index b26c323..b2bc6d1 100644 --- a/src/setup.rs +++ b/src/setup.rs @@ -119,8 +119,7 @@ fn update(state: &mut State, message: Message) -> Task { return Task::none(); }; state.stage = Stage::Installing; - state.status = - "Running installer via umu-run (this may take several minutes)…".into(); + state.status = "Running installer via umu-run (this may take several minutes)…".into(); if let Ok(mut v) = state.log.lock() { v.clear(); } @@ -165,11 +164,7 @@ fn subscription(state: &State) -> Subscription { fn view(state: &State) -> Element<'_, Message> { let header = text(format!("Setup: {}", state.launcher.display)).size(24); - let prefix = text(format!( - "Prefix: {}", - state.launcher.prefix_dir.display() - )) - .size(13); + let prefix = text(format!("Prefix: {}", state.launcher.prefix_dir.display())).size(13); let expected = text(format!( "Expected: {}", state.launcher.full_exe_path().display() @@ -180,8 +175,7 @@ fn view(state: &State) -> Element<'_, Message> { .on_input(Message::SourceChanged) .padding(8); - let prepare_enabled = - matches!(state.stage, Stage::Idle | Stage::Ready | Stage::Finished); + let prepare_enabled = matches!(state.stage, Stage::Idle | Stage::Ready | Stage::Finished); let install_enabled = matches!(state.stage, Stage::Ready); let prepare_btn = button(text("Download / Prepare"))