mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
Replace simple match with map_or
This commit is contained in:
+10
-14
@@ -9,23 +9,19 @@ fn get_block_size() -> u64 {
|
|||||||
#[cfg(target_family = "unix")]
|
#[cfg(target_family = "unix")]
|
||||||
pub fn get_metadata(d: &DirEntry, use_apparent_size: bool) -> Option<(u64, Option<(u64, u64)>)> {
|
pub fn get_metadata(d: &DirEntry, use_apparent_size: bool) -> Option<(u64, Option<(u64, u64)>)> {
|
||||||
use std::os::unix::fs::MetadataExt;
|
use std::os::unix::fs::MetadataExt;
|
||||||
match d.metadata().ok() {
|
d.metadata().ok().map_or(None, |md| {
|
||||||
Some(md) => {
|
let inode = Some((md.ino(), md.dev()));
|
||||||
let inode = Some((md.ino(), md.dev()));
|
if use_apparent_size {
|
||||||
if use_apparent_size {
|
Some((md.len(), inode))
|
||||||
Some((md.len(), inode))
|
} else {
|
||||||
} else {
|
Some((md.blocks() * get_block_size(), inode))
|
||||||
Some((md.blocks() * get_block_size(), inode))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
None => None,
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(target_family = "unix"))]
|
#[cfg(not(target_family = "unix"))]
|
||||||
pub fn get_metadata(d: &DirEntry, _apparent: bool) -> Option<(u64, Option<(u64, u64)>)> {
|
pub fn get_metadata(d: &DirEntry, _apparent: bool) -> Option<(u64, Option<(u64, u64)>)> {
|
||||||
match d.metadata().ok() {
|
d.metadata().ok().map_or(None, |md| {
|
||||||
Some(md) => Some((md.len(), None)),
|
Some((md.len(), None))
|
||||||
None => None,
|
})
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user