clippy: Use matches! in place of if let .. else expression

This commit is contained in:
Jack Grigg 2021-03-04 17:47:25 +00:00
parent d221b230c6
commit b5bbd52c68
2 changed files with 6 additions and 16 deletions

View File

@ -34,11 +34,7 @@ impl Entry {
/// Is this node a leaf. /// Is this node a leaf.
pub fn leaf(&self) -> bool { pub fn leaf(&self) -> bool {
if let EntryKind::Leaf = self.kind { matches!(self.kind, EntryKind::Leaf)
true
} else {
false
}
} }
/// Left child /// Left child

View File

@ -648,7 +648,7 @@ mod tests {
tree.truncate_leaf().expect("Failed to truncate"); tree.truncate_leaf().expect("Failed to truncate");
} }
TestResult::from_bool(if let EntryLink::Stored(2) = tree.root() { true } else { false }) TestResult::from_bool(matches!(tree.root(), EntryLink::Stored(2)))
} }
} }
@ -678,12 +678,9 @@ mod tests {
TestResult::from_bool( TestResult::from_bool(
if number & (number - 1) == 0 { if number & (number - 1) == 0 {
if let EntryLink::Stored(_) = tree.root() { true } matches!(tree.root(), EntryLink::Stored(_))
else { false }
} else if let EntryLink::Generated(_) = tree.root() {
true
} else { } else {
false matches!(tree.root(), EntryLink::Generated(_))
} }
) )
} }
@ -707,12 +704,9 @@ mod tests {
TestResult::from_bool( TestResult::from_bool(
if total & (total - 1) == 0 { if total & (total - 1) == 0 {
if let EntryLink::Stored(_) = tree.root() { true } matches!(tree.root(), EntryLink::Stored(_))
else { false }
} else if let EntryLink::Generated(_) = tree.root() {
true
} else { } else {
false matches!(tree.root(), EntryLink::Generated(_))
} }
) )
} }