summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYves Fischer <yvesf-git@xapek.org>2019-01-29 00:20:04 +0100
committerYves Fischer <yvesf-git@xapek.org>2019-01-29 01:17:32 +0100
commit2cc60bccef46fa381c49a7583038cbbb7bfcfe8e (patch)
treef95d1c92809102d6ddad5c586dd58a41e665faae
parentb49a80e2a63c6cd7e627192a6e62133debfc5cd0 (diff)
downloadbatteriewarner-2cc60bccef46fa381c49a7583038cbbb7bfcfe8e.tar.gz
batteriewarner-2cc60bccef46fa381c49a7583038cbbb7bfcfe8e.zip
Fix code-linter warnings from clippy
-rw-r--r--src/main.rs17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/main.rs b/src/main.rs
index 4632f6f..338c6f7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -6,9 +6,9 @@ use std::path::Path;
use std::thread::sleep;
use std::time::Duration;
-const PATH_ENERGY_NOW: &'static str = "/sys/class/power_supply/BAT0/energy_now";
-const PATH_ENERGY_FULL: &'static str = "/sys/class/power_supply/BAT0/energy_full_design";
-const PATH_LIGHT: &'static str = "/sys/devices/platform/thinkpad_acpi/leds/tpacpi::power/brightness";
+const PATH_ENERGY_NOW: &str = "/sys/class/power_supply/BAT0/energy_now";
+const PATH_ENERGY_FULL: &str = "/sys/class/power_supply/BAT0/energy_full_design";
+const PATH_LIGHT: &str = "/sys/devices/platform/thinkpad_acpi/leds/tpacpi::power/brightness";
fn file_read_integer<P: AsRef<Path>>(path: P) -> Result<u64> {
let mut buf = [0; 20];
@@ -53,9 +53,9 @@ fn indicate_battery_level(level: u32) -> Result<()> {
let n = flashing_time / (level * offtime + level * ontime);
for _ in 0..n {
write_brightness(0)?;
- sleep(Duration::from_millis((level * offtime) as u64));
+ sleep(Duration::from_millis(u64::from(level * offtime)));
write_brightness(1)?;
- sleep(Duration::from_millis((level * ontime) as u64));
+ sleep(Duration::from_millis(u64::from(level * ontime)));
}
write_brightness(led_state)?;
Ok(())
@@ -67,9 +67,8 @@ fn main() {
match p {
Ok(level) => {
if level < 20 {
- match indicate_battery_level(level) {
- Err(e) => panic!("Error: {}", e),
- _ => {}
+ if let Err(e) = indicate_battery_level(level) {
+ panic!("Error: {}", e);
}
}
}
@@ -77,4 +76,4 @@ fn main() {
}
sleep(Duration::from_secs(10));
}
-} \ No newline at end of file
+}