Skip to content

Commit

Permalink
style: clippy
Browse files Browse the repository at this point in the history
bpetit committed Jan 5, 2024
1 parent 759ab4c commit 839d660
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
@@ -167,7 +167,7 @@ fn my_service_main(_arguments: Vec<OsString>) {
"Starting main thread, service status has been set: {:?}",
status_set
);
thread_handle = Some(thread::spawn(move || {
thread_handle = Some(std::thread::spawn(move || {
parse_cli_and_run_exporter();
}));
}
10 changes: 5 additions & 5 deletions src/sensors/utils.rs
Original file line number Diff line number Diff line change
@@ -324,7 +324,7 @@ impl ProcessTracker {
// check if the previous records in the vector are from the same process
// (if the process with that pid is not a new one) and if so, drop it for a new one
if !vector.is_empty()
&& process_record.process.comm != vector.get(0).unwrap().process.comm
&& process_record.process.comm != vector.first().unwrap().process.comm
{
*vector = vec![];
}
@@ -627,22 +627,22 @@ impl ProcessTracker {
let mut result = self
.procs
.iter()
.filter(|x| !x.is_empty() && x.get(0).unwrap().process.pid == pid);
.filter(|x| !x.is_empty() && x.first().unwrap().process.pid == pid);
let process = result.next().unwrap();
if result.next().is_some() {
panic!("Found two vectors of processes with the same id, maintainers should fix this.");
}
process.get(0).unwrap().process.comm.clone()
process.first().unwrap().process.comm.clone()
}

/// Returns the cmdline string associated to a PID
pub fn get_process_cmdline(&self, pid: Pid) -> Option<String> {
let mut result = self
.procs
.iter()
.filter(|x| !x.is_empty() && x.get(0).unwrap().process.pid == pid);
.filter(|x| !x.is_empty() && x.first().unwrap().process.pid == pid);
let process = result.next().unwrap();
if let Some(p) = process.get(0) {
if let Some(p) = process.first() {
let cmdline_request = p.process.cmdline(self);
if let Ok(mut cmdline_vec) = cmdline_request {
let mut cmdline = String::from("");

0 comments on commit 839d660

Please sign in to comment.