chore:: clippy

This commit is contained in:
Vukašin Vojinović 2026-04-27 13:18:15 +02:00 • committed by Michael Murphy
parent ec1b80534a
commit a7ca33b6eb
7 changed files with 120 additions and 121 deletions

View file

@ -52,26 +52,26 @@ pub async fn handler(msg_tx: &mut mpsc::Sender<Option<(f64, bool, bool)>>) -> Re
loop {
let mut info_opt = None;
if let Ok(mut percent) = dev.percentage().await {
if let Ok(state) = dev.state().await {
let threshold_enabled = dev.charge_threshold_enabled().await.unwrap_or_default();
let mut capacity = dev.capacity().await.unwrap_or(100.);
if capacity <= 1. {
capacity = 100.;
}
// compensate for declining battery capacity
percent = percent * 100. / capacity;
if matches!(state, BatteryState::FullyCharged) || percent >= 100. {
percent = 100.;
}
info_opt = Some((
percent,
state == BatteryState::Discharging,
threshold_enabled,
));
if let Ok(mut percent) = dev.percentage().await
&& let Ok(state) = dev.state().await
{
let threshold_enabled = dev.charge_threshold_enabled().await.unwrap_or_default();
let mut capacity = dev.capacity().await.unwrap_or(100.);
if capacity <= 1. {
capacity = 100.;
}
// compensate for declining battery capacity
percent = percent * 100. / capacity;
if matches!(state, BatteryState::FullyCharged) || percent >= 100. {
percent = 100.;
}
info_opt = Some((
percent,
state == BatteryState::Discharging,
threshold_enabled,
));
}
msg_tx.send(info_opt).await.unwrap();