1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-02 05:57:46 +00:00

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,9 +55,8 @@ 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(),
@ -68,9 +67,6 @@ impl Stat {
modified: metadata.mtime() as u64, modified: metadata.mtime() as u64,
}) })
} }
Err(e) => Err(e),
}
}
} }
// this takes `my_stat` to avoid having to stat files multiple times. // this takes `my_stat` to avoid having to stat files multiple times.