From fed18d37266852d959a87250c83f75e4d2db29f0 Mon Sep 17 00:00:00 2001 From: "daniel.eades" Date: Thu, 16 Nov 2023 18:07:40 +0000 Subject: [PATCH] avoid single variant match statements --- cosmic-applet-network/src/app.rs | 59 ++++++++----------- .../status_notifier_watcher/server.rs | 7 +-- 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/cosmic-applet-network/src/app.rs b/cosmic-applet-network/src/app.rs index 612f98ae..69fae6e6 100644 --- a/cosmic-applet-network/src/app.rs +++ b/cosmic-applet-network/src/app.rs @@ -289,18 +289,15 @@ impl cosmic::Application for CosmicNetworkApplet { } } if !success { - match req { - NetworkManagerRequest::Password(_, _) => { - if let Some( - NewConnectionState::EnterPassword { access_point, .. } - | NewConnectionState::Waiting(access_point), - ) = self.new_connection.as_ref() - { - self.new_connection - .replace(NewConnectionState::Failure(access_point.clone())); - } + if let NetworkManagerRequest::Password(_, _) = req { + if let Some( + NewConnectionState::EnterPassword { access_point, .. } + | NewConnectionState::Waiting(access_point), + ) = self.new_connection.as_ref() + { + self.new_connection + .replace(NewConnectionState::Failure(access_point.clone())); } - _ => {} } } self.update_nm_state(state); @@ -327,12 +324,13 @@ impl cosmic::Application for CosmicNetworkApplet { self.new_connection.take(); self.show_visible_networks = !self.show_visible_networks; } - Message::Password(entered_pw) => match &mut self.new_connection { - Some(NewConnectionState::EnterPassword { password, .. }) => { + Message::Password(entered_pw) => { + if let Some(NewConnectionState::EnterPassword { password, .. }) = + &mut self.new_connection + { *password = entered_pw; } - _ => {} - }, + } Message::SubmitPassword => { // save password let tx = if let Some(tx) = self.nm_sender.as_ref() { @@ -341,19 +339,17 @@ impl cosmic::Application for CosmicNetworkApplet { return Command::none(); }; - match self.new_connection.take() { - Some(NewConnectionState::EnterPassword { - password, - access_point, - }) => { - let _ = tx.unbounded_send(NetworkManagerRequest::Password( - access_point.ssid.clone(), - password.to_string(), - )); - self.new_connection - .replace(NewConnectionState::Waiting(access_point.clone())); - } - _ => {} + if let Some(NewConnectionState::EnterPassword { + password, + access_point, + }) = self.new_connection.take() + { + let _ = tx.unbounded_send(NetworkManagerRequest::Password( + access_point.ssid.clone(), + password.to_string(), + )); + self.new_connection + .replace(NewConnectionState::Waiting(access_point.clone())); }; } Message::ActivateKnownWifi(ssid) => { @@ -383,11 +379,8 @@ impl cosmic::Application for CosmicNetworkApplet { .iter_mut() .find(|c| c.name() == ssid) { - match ap { - ActiveConnectionInfo::WiFi { state, .. } => { - *state = ActiveConnectionState::Deactivating; - } - _ => {} + if let ActiveConnectionInfo::WiFi { state, .. } = ap { + *state = ActiveConnectionState::Deactivating; } } tx diff --git a/cosmic-applet-status-area/src/subscriptions/status_notifier_watcher/server.rs b/cosmic-applet-status-area/src/subscriptions/status_notifier_watcher/server.rs index 91c20ef4..4352064c 100644 --- a/cosmic-applet-status-area/src/subscriptions/status_notifier_watcher/server.rs +++ b/cosmic-applet-status-area/src/subscriptions/status_notifier_watcher/server.rs @@ -90,11 +90,8 @@ pub async fn create_service(connection: &zbus::Connection) -> zbus::Result<()> { let mut name_owner_changed_stream = dbus_proxy.receive_name_owner_changed().await?; let flags = RequestNameFlags::AllowReplacement.into(); - match dbus_proxy.request_name(NAME.as_ref(), flags).await? { - RequestNameReply::InQueue => { - eprintln!("Bus name '{}' already owned", NAME); - } - _ => {} + if dbus_proxy.request_name(NAME.as_ref(), flags).await? == RequestNameReply::InQueue { + eprintln!("Bus name '{}' already owned", NAME); } let connection = connection.clone();