diff --git a/rust/src/nasl/builtin/sys/mod.rs b/rust/src/nasl/builtin/sys/mod.rs index ef42d8461..d9b2b5f4d 100644 --- a/rust/src/nasl/builtin/sys/mod.rs +++ b/rust/src/nasl/builtin/sys/mod.rs @@ -37,7 +37,7 @@ async fn find_path_of_command(cmd: &str) -> Result { if output.status.success() { let stdout = String::from_utf8(output.stdout).map_err(|_| make_err())?; let path = Path::new(&stdout); - let dir = path.parent().ok_or_else(|| make_err())?.to_owned(); + let dir = path.parent().ok_or_else(make_err)?.to_owned(); Ok(dir) } else { Err(SysError::CommandNotFound(cmd.to_string())) @@ -61,10 +61,7 @@ async fn pread( for arg in argv.iter() { real_cmd.arg(arg); } - let out = real_cmd - .output() - .await - .map_err(|e| SysError::SpawnProcess(e))?; + let out = real_cmd.output().await.map_err(SysError::SpawnProcess)?; let stdout = String::from_utf8(out.stdout).unwrap(); Ok(stdout) } @@ -90,7 +87,7 @@ async fn fread(path: &Path) -> Result { async fn fwrite(data: &str, file: &Path) -> Result { tokio::fs::write(file, data) .await - .map_err(|e| SysError::WriteFile(e))?; + .map_err(SysError::WriteFile)?; let num_bytes = data.len(); Ok(num_bytes) } @@ -99,7 +96,7 @@ async fn fwrite(data: &str, file: &Path) -> Result { async fn file_stat(path: &Path) -> Result { let metadata = tokio::fs::metadata(path) .await - .map_err(|e| SysError::ReadFileMetadata(e))?; + .map_err(SysError::ReadFileMetadata)?; Ok(metadata.len()) }