du: refactor to use ? shortcut

This commit is contained in:
bootandy 2018-03-15 14:56:21 -04:00
parent be79a70572
commit 8f67c8fef2

View file

@ -55,21 +55,17 @@ struct Stat {
impl Stat { impl Stat {
fn new(path: PathBuf) -> Result<Stat> { fn new(path: PathBuf) -> Result<Stat> {
match fs::symlink_metadata(&path) { let metadata = fs::symlink_metadata(&path)?;
Ok(metadata) => { Ok(Stat {
return Ok(Stat { path: path,
path: path, is_dir: metadata.is_dir(),
is_dir: metadata.is_dir(), size: metadata.len(),
size: metadata.len(), blocks: metadata.blocks() as u64,
blocks: metadata.blocks() as u64, nlink: metadata.nlink() as u64,
nlink: metadata.nlink() as u64, created: metadata.mtime() as u64,
created: metadata.mtime() as u64, accessed: metadata.atime() as u64,
accessed: metadata.atime() as u64, modified: metadata.mtime() as u64,
modified: metadata.mtime() as u64, })
})
}
Err(e) => Err(e),
}
} }
} }