From ff48e5c1dd789402c5b1423ace9e8577c25ae5d7 Mon Sep 17 00:00:00 2001 From: TQ Hirsch Date: Wed, 4 May 2022 19:04:52 +0200 Subject: [PATCH] Cleaned up all of the warnings --- src/main.rs | 8 +++----- src/upower.rs | 16 ++-------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7297e9f..c0100d0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,10 +5,8 @@ pub mod upower; use std::cell::Cell; use std::sync::RwLock; use std::{cell::RefCell, rc::Rc, sync::Arc}; -use std::cmp::min; -use std::os::linux::raw::stat; use palette::convert::FromColorUnclamped; -use palette::{Blend, FromColor, IntoColor, LinSrgba, Mix, Oklab, Oklaba, Packed, Pixel, Shade, Srgb, Srgba}; +use palette::{FromColor, LinSrgba, Mix, Oklaba, Shade, Srgba}; use wayland_client::{ protocol::{wl_output::WlOutput, wl_shm, wl_surface::WlSurface}, Attached, Main, @@ -32,6 +30,7 @@ pub struct PowerState { /// True if line power is available. charging: bool, /// Time to full charge/empty, in seconds + #[allow(unused)] // TODO: actually use this to display the time remaining time_remaining: f32, } @@ -227,7 +226,7 @@ impl Drop for Surface { fn main() -> anyhow::Result<()> { - let mut app_state = AppState::default(); + let app_state = AppState::default(); // Spawn upower watcher let upower_channel = { @@ -284,7 +283,6 @@ fn main() -> anyhow::Result<()> { let mut event_loop = calloop::EventLoop::<()>::try_new().expect("Failed to start event loop"); let surfaces_handle = Rc::clone(&surfaces); - let power_state_handle = Arc::clone(&app_state.display_status); event_loop.handle().insert_source( upower_channel, move |_, _, _| { diff --git a/src/upower.rs b/src/upower.rs index 341d3cc..e22b8e0 100644 --- a/src/upower.rs +++ b/src/upower.rs @@ -2,7 +2,6 @@ use std::collections::HashMap; use crate::PowerState; use std::sync::mpsc::SyncSender; use std::sync::{ - mpsc::{Receiver, Sender}, Arc, RwLock, }; use upower_dbus; @@ -17,17 +16,6 @@ pub struct PowerReporter { pub status: Arc>>, } -pub struct PowerReceiver { - receiver: Receiver<()>, - status: Arc>>, -} - -macro_rules! catch { - ($expr:block) => { - (|| $expr)() - }; -} - pub fn spawn_mock(reporter: PowerReporter) -> anyhow::Result<()> { std::thread::spawn(move || { *reporter.status.write().unwrap() = Some(PowerState{ @@ -54,7 +42,7 @@ pub fn spawn_upower(reporter: PowerReporter) -> anyhow::Result<()> { std::thread::spawn(move || { let failure = upower_run(reporter, &start_send); if failure.is_err() { - start_send.send(failure); + start_send.send(failure).unwrap(); } }); @@ -101,7 +89,7 @@ fn upower_run( .cache_properties(zbus::CacheProperties::No) .build()?; - let mut prop_changed_iterator = display_proxy.receive_properties_changed()?; + let prop_changed_iterator = display_proxy.receive_properties_changed()?; let device_interface_name = zbus::names::InterfaceName::from_static_str("org.freedesktop.UPower.Device").unwrap();