some changes

This commit is contained in:
2024-12-30 19:38:37 +00:00
parent 7095a197c6
commit 1dbd53a347
2 changed files with 3 additions and 3 deletions
+1
View File
@@ -1,4 +1,5 @@
#![allow(clippy::module_inception)] #![allow(clippy::module_inception)]
#![allow(clippy::module_name_repetitions)]
mod handle; mod handle;
mod memory; mod memory;
+2 -3
View File
@@ -21,15 +21,14 @@ pub enum Identifier {
impl Process { impl Process {
pub fn from(identifier: &Identifier) -> Result<Self, crate::Error> { pub fn from(identifier: &Identifier) -> Result<Self, crate::Error> {
let snapshot = match identifier { let Some(snapshot) = (match identifier {
Identifier::Id(pid) => ProcessSnapshot::get_processes()? Identifier::Id(pid) => ProcessSnapshot::get_processes()?
.into_iter() .into_iter()
.find(|snapshot| snapshot.id == *pid), .find(|snapshot| snapshot.id == *pid),
Identifier::Name(ref name) => ProcessSnapshot::get_processes()? Identifier::Name(ref name) => ProcessSnapshot::get_processes()?
.into_iter() .into_iter()
.find(|snapshot| snapshot.name == *name), .find(|snapshot| snapshot.name == *name),
}; }) else {
let Some(snapshot) = snapshot else {
return Err(crate::Error::ProcessError(format!( return Err(crate::Error::ProcessError(format!(
"failed to find a process with identifier `{identifier}`", "failed to find a process with identifier `{identifier}`",
))); )));