From 638f2a20d2f4901da2333cb18223872f3532341f Mon Sep 17 00:00:00 2001 From: Rodrigodd Date: Sat, 19 Apr 2025 20:53:37 -0300 Subject: [PATCH] refactor: avoid explicity cast with long type Aparently Rust doesn't implicitly cast a `Result>` to `Result>`, so the `Result` was being mapped with a explicity cast. But unwrapping the `Result` with a `?` and then wrapping it back into `Ok` make the implicit cast work. This avoid typing the entire type, which was breaking the code in multiple lines. --- src/clients/compositor/mod.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/clients/compositor/mod.rs b/src/clients/compositor/mod.rs index e9397a8..8d07ddc 100644 --- a/src/clients/compositor/mod.rs +++ b/src/clients/compositor/mod.rs @@ -74,9 +74,7 @@ impl Compositor { debug!("Getting keyboard_layout client for: {current}"); match current { #[cfg(feature = "bindmode+sway")] - Self::Sway => clients - .sway() - .map(|client| client as Arc), + Self::Sway => Ok(clients.sway()?), #[cfg(feature = "bindmode+hyprland")] Self::Hyprland => Ok(clients.hyprland()), #[cfg(feature = "niri")] @@ -98,9 +96,7 @@ impl Compositor { debug!("Getting keyboard_layout client for: {current}"); match current { #[cfg(feature = "keyboard+sway")] - Self::Sway => clients - .sway() - .map(|client| client as Arc), + Self::Sway => Ok(clients.sway()?), #[cfg(feature = "keyboard+hyprland")] Self::Hyprland => Ok(clients.hyprland()), #[cfg(feature = "niri")] @@ -126,9 +122,7 @@ impl Compositor { debug!("Getting workspace client for: {current}"); match current { #[cfg(feature = "workspaces+sway")] - Self::Sway => clients - .sway() - .map(|client| client as Arc), + Self::Sway => Ok(clients.sway()?), #[cfg(feature = "workspaces+hyprland")] Self::Hyprland => Ok(clients.hyprland()), #[cfg(feature = "workspaces+niri")]