Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
fix(desktop): clear clippy lints in the Windows broker (#4438)
Will Herr4ea9170f8188
diff --git a/harper-desktop/src-tauri/src/windows_broker/automation_service.rs b/harper-desktop/src-tauri/src/windows_broker/automation_service.rsindex 79b71c7df..7658928c0 100644--- a/harper-desktop/src-tauri/src/windows_broker/automation_service.rs+++ b/harper-desktop/src-tauri/src/windows_broker/automation_service.rs@@ -92,10 +92,8 @@ impl AutomationService {let result = job(&automation, arguments);// Stop the thread if the other side of the channel has been closed (or dropped).- if let Err(err) = result_sender.try_send(result) {- if let TrySendError::Disconnected(_) = err {- break;- }+ if let Err(TrySendError::Disconnected(_)) = result_sender.try_send(result) {+ break;}}diff --git a/harper-desktop/src-tauri/src/windows_broker/mod.rs b/harper-desktop/src-tauri/src/windows_broker/mod.rsindex 2840de065..a094fbb89 100644--- a/harper-desktop/src-tauri/src/windows_broker/mod.rs+++ b/harper-desktop/src-tauri/src/windows_broker/mod.rs@@ -177,15 +177,12 @@ impl OsBroker for WindowsBroker {}fn application_icon_png(&self, bundle_id: &str) -> Result<Vec<u8>, String> {- if let Some(entry) = look_up_application(bundle_id) {- if let Some(png) = entry.icon_png {- return Ok(png);- } else {- return Err("Found application but it was missing an icon.".to_string());- }- } else {- return Err("Unable to locate application.".to_string());- }+ let entry = look_up_application(bundle_id)+ .ok_or_else(|| "Unable to locate application.".to_string())?;++ entry+ .icon_png+ .ok_or_else(|| "Found application but it was missing an icon.".to_string())}fn launch_app_bundle(&self, bundle_id: &str) -> Result<(), String> {@@ -223,7 +220,6 @@ impl OsBroker for WindowsBroker {.to_lowercase().contains(&lower_query)})- .cloned().map(|entry| entry.to_search_result()).collect())}@@ -260,8 +256,7 @@ fn get_focused_monitor_scale() -> f64 {let _ = GetDpiForMonitor(monitor, MDT_EFFECTIVE_DPI, &mut x, &mut y);- let effective_scale = x as f64 / 96.;- effective_scale+ x as f64 / 96.}}@@ -277,7 +272,7 @@ impl ApplicationListEntry {fn to_search_result(&self) -> AppSearchResult {AppSearchResult {name: self.display_name.clone(),- bundle_id: self.path.to_string_lossy().to_owned().to_string(),+ bundle_id: self.path.to_string_lossy().into_owned(),}}}@@ -285,34 +280,27 @@ impl ApplicationListEntry {fn look_up_application(bundle_id: &str) -> Option<ApplicationListEntry> {// In Windows, the application path is the bundle ID.let list = installed_applications_list();- if let Some(entry) = list- .iter()+ list.iter().find(|entry| entry.path.to_string_lossy() == bundle_id)- {- Some(entry.clone())- } else {- None- }+ .cloned()}#[cached]fn installed_applications_list() -> Arc<Vec<ApplicationListEntry>> {let mut list = Vec::new();- for res in gatherer().scan() {- if let Ok(app) = res {- let icon = if let Ok(icon) = app.entry.icon() {- icon.extract_icon_as_png_at(IconSize::Jumbo)- } else {- None- };+ for app in gatherer().scan().flatten() {+ let icon = if let Ok(icon) = app.entry.icon() {+ icon.extract_icon_as_png_at(IconSize::Jumbo)+ } else {+ None+ };- list.push(ApplicationListEntry {- path: app.entry.path().to_owned(),- icon_png: icon,- display_name: app.entry.display_name(),- })- }+ list.push(ApplicationListEntry {+ path: app.entry.path().to_owned(),+ icon_png: icon,+ display_name: app.entry.display_name(),+ })}Arc::new(list)