some changes
This commit is contained in:
@@ -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;
|
||||||
|
|||||||
@@ -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}`",
|
||||||
)));
|
)));
|
||||||
|
|||||||
Reference in New Issue
Block a user