From 08e354e019d9e14a6df6ae8d29bb883b21bdb882 Mon Sep 17 00:00:00 2001 From: Jake Stanger Date: Thu, 19 Oct 2023 21:11:56 +0100 Subject: [PATCH] refactor: fix new clippy warnings --- src/clients/compositor/hyprland.rs | 9 ++++++--- src/clients/wayland/wlr_data_control/mod.rs | 2 +- src/ipc/server.rs | 2 +- src/script.rs | 4 ++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/clients/compositor/hyprland.rs b/src/clients/compositor/hyprland.rs index 699a2f7..6342ec1 100644 --- a/src/clients/compositor/hyprland.rs +++ b/src/clients/compositor/hyprland.rs @@ -5,7 +5,7 @@ use hyprland::data::{Workspace as HWorkspace, Workspaces}; use hyprland::dispatch::{Dispatch, DispatchType, WorkspaceIdentifierWithSpecial}; use hyprland::event_listener::EventListener; use hyprland::prelude::*; -use hyprland::shared::WorkspaceType; +use hyprland::shared::{HyprDataVec, WorkspaceType}; use lazy_static::lazy_static; use tokio::sync::broadcast::{channel, Receiver, Sender}; use tokio::task::spawn_blocking; @@ -260,9 +260,12 @@ fn get_workspace_name(name: WorkspaceType) -> String { } } -/// Creates a function which determines if a workspace is visible. This function makes a Hyprland call that allocates so it should be cached when possible, but it is only valid so long as workspaces do not change so it should not be stored long term +/// Creates a function which determines if a workspace is visible. +/// +/// This function makes a Hyprland call that allocates so it should be cached when possible, +/// but it is only valid so long as workspaces do not change so it should not be stored long term fn create_is_visible() -> impl Fn(&HWorkspace) -> bool { - let monitors = hyprland::data::Monitors::get().map_or(Vec::new(), |ms| ms.to_vec()); + let monitors = hyprland::data::Monitors::get().map_or(Vec::new(), HyprDataVec::to_vec); move |w| monitors.iter().any(|m| m.active_workspace.id == w.id) } diff --git a/src/clients/wayland/wlr_data_control/mod.rs b/src/clients/wayland/wlr_data_control/mod.rs index 7f9eb61..926869d 100644 --- a/src/clients/wayland/wlr_data_control/mod.rs +++ b/src/clients/wayland/wlr_data_control/mod.rs @@ -198,7 +198,7 @@ impl DataControlDeviceHandler for Environment { let token = self .loop_handle - .insert_source(read_pipe, move |_, file, state| { + .insert_source(read_pipe, move |(), file, state| { let item = state .selection_offers .iter() diff --git a/src/ipc/server.rs b/src/ipc/server.rs index 5878030..fb3c291 100644 --- a/src/ipc/server.rs +++ b/src/ipc/server.rs @@ -137,7 +137,7 @@ impl Ipc { let variable_manager = get_variable_manager(); let mut variable_manager = write_lock!(variable_manager); match variable_manager.set(key, value) { - Ok(_) => Response::Ok, + Ok(()) => Response::Ok, Err(err) => Response::error(&format!("{err}")), } } diff --git a/src/script.rs b/src/script.rs index 8fc38ca..47683c1 100644 --- a/src/script.rs +++ b/src/script.rs @@ -205,7 +205,7 @@ impl Script { Ok(output) => callback(output.0, output.1), Err(err) => error!("{err:?}"), }, - ScriptMode::Watch => match self.spawn().await { + ScriptMode::Watch => match self.spawn() { Ok(mut rx) => { while let Some(msg) = rx.recv().await { callback(msg, true); @@ -264,7 +264,7 @@ impl Script { /// Spawns a long-running process. /// Returns a `mpsc::Receiver` that sends a message /// every time a new line is written to `stdout` or `stderr`. - pub async fn spawn(&self) -> Result> { + pub fn spawn(&self) -> Result> { let mut handle = Command::new("/bin/sh") .args(["-c", &self.cmd]) .stdout(Stdio::piped())