From b2b7e023f2701d97bd5a60f75ac926b70e5159be Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Fri, 19 Apr 2024 16:05:34 +0200 Subject: [PATCH] Fix clippy warnings --- src/bin/main.rs | 1 - src/lib.rs | 2 +- src/py_module.rs | 13 +++++-------- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/bin/main.rs b/src/bin/main.rs index 2c2b95f..74f8cea 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -1,7 +1,6 @@ #![deny(warnings)] use anyhow::Context; use clap::Parser; -use env_logger; use std::convert::TryInto; use std::io::BufRead; use std::process::exit; diff --git a/src/lib.rs b/src/lib.rs index 73d6d2c..61d1cbe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -310,7 +310,7 @@ impl Ka3005p { let printable_ascii = |bytes: Vec| -> String { bytes .into_iter() - .filter(|&b| b >= 32 && b <= 126) + .filter(|&b| (32..=126).contains(&b)) .collect::>() .into_iter() .map(|b| b as char) diff --git a/src/py_module.rs b/src/py_module.rs index 04fa3cc..e9123bb 100644 --- a/src/py_module.rs +++ b/src/py_module.rs @@ -53,7 +53,7 @@ impl PowerSupply { Ok(self .inner .execute(command) - .map_err(|e| Into::::into(e))?) + .map_err(Into::::into)?) } /// Get the status of the power supply. @@ -61,10 +61,7 @@ impl PowerSupply { /// Returns: /// Status of the power supply. fn _status(&mut self) -> PyResult { - Ok(self - .inner - .status() - .map_err(|e| Into::::into(e))?) + Ok(self.inner.status().map_err(Into::::into)?) } } @@ -81,10 +78,10 @@ impl PowerSupply { fn new(serial_port: Option<&str>) -> PyResult { let supply = match serial_port { Some(port) => PowerSupply { - inner: Ka3005p::new(port).map_err(|e| Into::::into(e))?, + inner: Ka3005p::new(port).map_err(Into::::into)?, }, None => PowerSupply { - inner: find_serial_port().map_err(|e| Into::::into(e))?, + inner: find_serial_port().map_err(Into::::into)?, }, }; Ok(supply) @@ -113,7 +110,7 @@ impl PowerSupply { Ok(self .inner .run_command(command) - .map_err(|e| Into::::into(e))?) + .map_err(Into::::into)?) } /// Get the output current setting of the power supply.