From d1dcbd491589d51753b25a3addf733ef903c79c2 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 5 Jan 2023 09:58:48 -0800 Subject: [PATCH] battery: Fix clippy lints --- cosmic-applet-battery/src/app.rs | 2 +- cosmic-applet-battery/src/backlight.rs | 4 ++-- cosmic-applet-battery/src/upower_device.rs | 2 +- cosmic-applet-battery/src/upower_kbdbacklight.rs | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cosmic-applet-battery/src/app.rs b/cosmic-applet-battery/src/app.rs index 3828cd8d..b77f04b9 100644 --- a/cosmic-applet-battery/src/app.rs +++ b/cosmic-applet-battery/src/app.rs @@ -111,7 +111,7 @@ impl Application for CosmicBatteryApplet { } } Message::SetScreenBrightness(brightness) => { - self.screen_brightness = (brightness as f64 / 100.0).max(0.01).min(1.0); + self.screen_brightness = (brightness as f64 / 100.0).clamp(0.01, 1.0); if let Some(tx) = &self.screen_sender { let _ = tx.send(ScreenBacklightRequest::Set(self.screen_brightness)); } diff --git a/cosmic-applet-battery/src/backlight.rs b/cosmic-applet-battery/src/backlight.rs index db9a8705..aad39c06 100644 --- a/cosmic-applet-battery/src/backlight.rs +++ b/cosmic-applet-battery/src/backlight.rs @@ -114,10 +114,10 @@ async fn start_listening( let b = (backlight.brightness().await.unwrap_or_default() as f64 / backlight.max_brightness().await.unwrap_or(1) as f64) .clamp(0., 1.); - return ( + ( Some((id, ScreenBacklightUpdate::Init(tx, b))), State::Waiting(backlight, screen_proxy, rx), - ); + ) } State::Waiting(backlight, proxy, mut rx) => match rx.recv().await { Some(req) => match req { diff --git a/cosmic-applet-battery/src/upower_device.rs b/cosmic-applet-battery/src/upower_device.rs index 9a1f1dab..b1142789 100644 --- a/cosmic-applet-battery/src/upower_device.rs +++ b/cosmic-applet-battery/src/upower_device.rs @@ -199,7 +199,7 @@ async fn start_listening(id: I, state: State) -> (Option<(I, DeviceDbus State::Waiting(device), ); } - return (None, State::Finished); + (None, State::Finished) } State::Waiting(device) => { let mut stream = futures::stream_select!( diff --git a/cosmic-applet-battery/src/upower_kbdbacklight.rs b/cosmic-applet-battery/src/upower_kbdbacklight.rs index fa07c227..133c3c1a 100644 --- a/cosmic-applet-battery/src/upower_kbdbacklight.rs +++ b/cosmic-applet-battery/src/upower_kbdbacklight.rs @@ -66,10 +66,10 @@ async fn start_listening( let b = kbd_proxy.get_brightness().await.unwrap_or_default() as f64 / kbd_proxy.get_max_brightness().await.unwrap_or(1) as f64; - return ( + ( Some((id, KeyboardBacklightUpdate::Init(tx, b))), State::Waiting(kbd_proxy, rx), - ); + ) } State::Waiting(proxy, mut rx) => match rx.recv().await { Some(req) => match req {