Skip to content

Commit

Permalink
Resolve Clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
unlimitedsola authored and sharkdp committed Dec 31, 2024
1 parent 8a105e2 commit 69a1428
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use std::borrow::Cow;
use std::ffi::{OsStr, OsString};
use std::fmt::Write;
use std::fs;
use std::path::{Path, PathBuf};
use std::process::Command;
Expand Down Expand Up @@ -219,12 +220,13 @@ impl Collector for EnvironmentVariables {
let mut result = String::new();

for var in &self.list {
let value = std::env::var_os(&var).map(|value| value.to_string_lossy().into_owned());
let value = std::env::var_os(var).map(|value| value.to_string_lossy().into_owned());
let value: Option<String> =
value.map(|v| shell_escape::escape(Cow::Borrowed(&v)).into());

result += &format!(
"{}={}\n",
let _ = writeln!(
result,
"{}={}",
var.to_string_lossy(),
value.unwrap_or_else(|| "<not set>".into())
);
Expand Down
3 changes: 2 additions & 1 deletion src/collector/directory_entries.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fmt::Write;
use std::fs::{self, DirEntry};
use std::io::ErrorKind;
use std::path::{Path, PathBuf};
Expand Down Expand Up @@ -80,7 +81,7 @@ fn dir_entry_to_report_entry(dir_entry: DirEntry) -> String {

if let Ok(metadata) = dir_entry.metadata() {
if metadata.is_file() {
text.push_str(&format!(", {} bytes", metadata.len()));
let _ = write!(text, ", {} bytes", metadata.len());
} else if metadata.is_dir() {
text.push(std::path::MAIN_SEPARATOR);
}
Expand Down

0 comments on commit 69a1428

Please sign in to comment.