mirror of
https://github.com/uutils/coreutils
synced 2024-11-16 17:58:06 +00:00
du: refactor to use ? shortcut
This commit is contained in:
parent
be79a70572
commit
8f67c8fef2
1 changed files with 11 additions and 15 deletions
26
src/du/du.rs
26
src/du/du.rs
|
@ -55,21 +55,17 @@ struct Stat {
|
|||
|
||||
impl Stat {
|
||||
fn new(path: PathBuf) -> Result<Stat> {
|
||||
match fs::symlink_metadata(&path) {
|
||||
Ok(metadata) => {
|
||||
return Ok(Stat {
|
||||
path: path,
|
||||
is_dir: metadata.is_dir(),
|
||||
size: metadata.len(),
|
||||
blocks: metadata.blocks() as u64,
|
||||
nlink: metadata.nlink() as u64,
|
||||
created: metadata.mtime() as u64,
|
||||
accessed: metadata.atime() as u64,
|
||||
modified: metadata.mtime() as u64,
|
||||
})
|
||||
}
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
let metadata = fs::symlink_metadata(&path)?;
|
||||
Ok(Stat {
|
||||
path: path,
|
||||
is_dir: metadata.is_dir(),
|
||||
size: metadata.len(),
|
||||
blocks: metadata.blocks() as u64,
|
||||
nlink: metadata.nlink() as u64,
|
||||
created: metadata.mtime() as u64,
|
||||
accessed: metadata.atime() as u64,
|
||||
modified: metadata.mtime() as u64,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue