Refactor ~ use AsRef<Path> where possible

This commit is contained in:
Roy Ivy III
2020-01-29 22:25:35 -06:00
parent 9d4531d48b
commit a3d8fc00e1
3 changed files with 17 additions and 15 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ use jwalk::DirEntry;
#[allow(unused_imports)]
use std::fs;
use std::io;
use std::path::PathBuf;
use std::path::Path;
#[cfg(target_family = "unix")]
fn get_block_size() -> u64 {
@@ -49,14 +49,14 @@ pub fn get_metadata(d: &DirEntry, _apparent: bool) -> Option<(u64, Option<(u64,
}
#[cfg(target_family = "unix")]
pub fn get_filesystem(file_path: &PathBuf) -> Result<u64, io::Error> {
pub fn get_filesystem<P: AsRef<Path>>(file_path: P) -> Result<u64, io::Error> {
use std::os::unix::fs::MetadataExt;
let metadata = fs::metadata(file_path)?;
Ok(metadata.dev())
}
#[cfg(target_family = "windows")]
pub fn get_filesystem(file_path: &PathBuf) -> Result<u64, io::Error> {
pub fn get_filesystem<P: AsRef<Path>>(file_path: P) -> Result<u64, io::Error> {
use winapi_util::file::information;
use winapi_util::Handle;