refactor: Fix clippy lint for entry vacancy check ()

This commit is contained in:
Clement Tsang 2021-06-18 15:35:19 -07:00 committed by GitHub
parent 5d3d96dead
commit e3ebc48ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions
src/app/data_harvester/processes

View File

@ -1,5 +1,7 @@
//! Process data collection for Linux.
use std::collections::hash_map::Entry;
use crate::utils::error::{self, BottomError};
use crate::Pid;
@ -232,9 +234,9 @@ pub fn get_process_data(
if let Ok(dir) = dir {
if let Ok(pid) = dir.file_name().to_string_lossy().trim().parse::<Pid>() {
let mut fresh = false;
if !pid_mapping.contains_key(&pid) {
if let Entry::Vacant(entry) = pid_mapping.entry(pid) {
if let Ok(ppd) = PrevProcDetails::new(pid) {
pid_mapping.insert(pid, ppd);
entry.insert(ppd);
fresh = true;
} else {
// Bail early.