Refactor: use if let instead of is_some

This commit is contained in:
andy.boot
2020-02-09 13:48:23 +00:00
parent b6aa1378de
commit be2250d241
+8 -8
View File
@@ -173,16 +173,12 @@ fn should_ignore_file(
inodes: &mut HashSet<(u64, u64)>, inodes: &mut HashSet<(u64, u64)>,
maybe_inode: Option<(u64, u64)>, maybe_inode: Option<(u64, u64)>,
) -> bool { ) -> bool {
if let Some(inode_dev_pair) = maybe_inode { if let Some(inode_dev_pair) = maybe_inode {
// Ignore files on different devices (if flag applied) // Ignore files on different devices (if flag applied)
if restricted_filesystems.is_some() if let Some(rs) = restricted_filesystems {
&& !restricted_filesystems if !rs.contains(&inode_dev_pair.1) {
.as_ref() return true;
.unwrap() }
.contains(&inode_dev_pair.1)
{
return true;
} }
if !apparent_size { if !apparent_size {
@@ -382,5 +378,9 @@ mod tests {
let new_file = (11, 12); let new_file = (11, 12);
assert!(should_ignore_file(false, &od, &mut files, Some(new_file))); assert!(should_ignore_file(false, &od, &mut files, Some(new_file)));
assert!(should_ignore_file(true, &od, &mut files, Some(new_file))); assert!(should_ignore_file(true, &od, &mut files, Some(new_file)));
// We do not ignore files on the same device
assert!(!should_ignore_file(false, &od, &mut files, Some((2, 99))));
assert!(!should_ignore_file(true, &od, &mut files, Some((2, 99))));
} }
} }