Skip to content

Commit c8d5a32

Browse files
committed
make time_to_sleep of type duration instead of int
1 parent 3ae8f94 commit c8d5a32

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

services/power-panic/src/main.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,16 @@ async fn main() -> Result<()> {
7878
let battery = get_battery_info().await?;
7979
println!("Battery: {:?}", battery);
8080

81-
let mut time_to_sleep = 60;
81+
let mut time_to_sleep = Duration::from_secs(60);
8282

8383
let battery_is_low = battery.charge < 0.20;
8484
let battery_is_charging = battery.current > 0.0;
8585

8686
if battery_is_low && !battery_is_charging {
8787
audio_player.play();
88-
time_to_sleep = (battery.charge * 100.0) as u64;
88+
time_to_sleep = Duration::from_secs((battery.charge * 100.0) as u64);
8989
}
9090

91-
sleep(Duration::from_secs(time_to_sleep));
91+
sleep(time_to_sleep);
9292
}
9393
}

0 commit comments

Comments
 (0)