Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicoretti committed Apr 19, 2024
1 parent 887bc4a commit b2b7e02
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ impl Ka3005p {
let printable_ascii = |bytes: Vec<u8>| -> String {
bytes
.into_iter()
.filter(|&b| b >= 32 && b <= 126)
.filter(|&b| (32..=126).contains(&b))
.collect::<Vec<u8>>()
.into_iter()
.map(|b| b as char)
Expand Down
13 changes: 5 additions & 8 deletions src/py_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,15 @@ impl PowerSupply {
Ok(self
.inner
.execute(command)
.map_err(|e| Into::<Ka3005pError>::into(e))?)
.map_err(Into::<Ka3005pError>::into)?)
}

/// Get the status of the power supply.
///
/// Returns:
/// Status of the power supply.
fn _status(&mut self) -> PyResult<Status> {
Ok(self
.inner
.status()
.map_err(|e| Into::<Ka3005pError>::into(e))?)
Ok(self.inner.status().map_err(Into::<Ka3005pError>::into)?)
}
}

Expand All @@ -81,10 +78,10 @@ impl PowerSupply {
fn new(serial_port: Option<&str>) -> PyResult<Self> {
let supply = match serial_port {
Some(port) => PowerSupply {
inner: Ka3005p::new(port).map_err(|e| Into::<Ka3005pError>::into(e))?,
inner: Ka3005p::new(port).map_err(Into::<Ka3005pError>::into)?,
},
None => PowerSupply {
inner: find_serial_port().map_err(|e| Into::<Ka3005pError>::into(e))?,
inner: find_serial_port().map_err(Into::<Ka3005pError>::into)?,
},
};
Ok(supply)
Expand Down Expand Up @@ -113,7 +110,7 @@ impl PowerSupply {
Ok(self
.inner
.run_command(command)
.map_err(|e| Into::<Ka3005pError>::into(e))?)
.map_err(Into::<Ka3005pError>::into)?)
}

/// Get the output current setting of the power supply.
Expand Down

0 comments on commit b2b7e02

Please sign in to comment.