diff --git a/src/lib.rs b/src/lib.rs index c4e8219f..cd19ce3a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,7 @@ mod rayon; use std::{ fs::{File, Metadata}, io::{BufWriter, Read, Write, stdin, stdout}, - path::Path, + path::{Path, PathBuf}, sync::{ Arc, atomic::{AtomicBool, Ordering}, @@ -275,7 +275,7 @@ pub fn optimize(input: &InFile, output: &OutFile, opts: &Options) -> PngResult<( (OutFile::Path { path, .. }, _) => { let output_path = path .as_ref() - .map(|p| p.as_path()) + .map(PathBuf::as_path) .unwrap_or_else(|| input.path().unwrap()); let out_file = File::create(output_path) .map_err(|err| PngError::WriteFailed(output_path.display().to_string(), err))?; diff --git a/src/main.rs b/src/main.rs index 92b4583c..ecc26bf7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,12 @@ mod rayon; #[cfg(feature = "zopfli")] use std::num::NonZeroU64; use std::{ - ffi::OsString, fs::DirBuilder, io::Write, path::PathBuf, process::ExitCode, time::Duration, + ffi::{OsStr, OsString}, + fs::DirBuilder, + io::Write, + path::PathBuf, + process::ExitCode, + time::Duration, }; use clap::ArgMatches; @@ -143,7 +148,7 @@ fn collect_files( } else { // Skip non png files if not given on top level if !top_level && { - let extension = input.extension().map(|f| f.to_ascii_lowercase()); + let extension = input.extension().map(OsStr::to_ascii_lowercase); extension != Some(OsString::from("png")) && extension != Some(OsString::from("apng")) } {