From 26b773c64327b2597b2d0188983488a1b051845b Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Mon, 7 Apr 2025 08:20:51 -0700 Subject: [PATCH] Use `match` instead of a couple `if let` branches --- src/main.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8046ecd..70414d1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -631,26 +631,22 @@ impl Application for App { } fn subscription(&self) -> Subscription { - let events = iced::event::listen_with(|evt, _, _| { - if let iced::Event::PlatformSpecific(iced::event::PlatformSpecific::Wayland(evt)) = evt - { + let events = iced::event::listen_with(|evt, _, _| match evt { + iced::Event::PlatformSpecific(iced::event::PlatformSpecific::Wayland(evt)) => { if !matches!(evt, WaylandEvent::RequestResize) { Some(Msg::WaylandEvent(evt)) } else { None } - } else if let iced::Event::Keyboard(iced::keyboard::Event::KeyReleased { + } + iced::Event::Keyboard(iced::keyboard::Event::KeyReleased { key: Key::Named(Named::Escape), modifiers: _, location: _, modified_key: _, physical_key: _, - }) = evt - { - Some(Msg::Close) - } else { - None - } + }) => Some(Msg::Close), + _ => None, }); let config_subscription = cosmic_config::config_subscription::<_, CosmicWorkspacesConfig>( "config-sub",